如何在我的中启用复制,treeviewitem
以便我可以复制 treeview selecteditem 中的文本并将其粘贴到其他地方。我在 wpf 的树视图中找不到这样的属性。
这是我的代码
<TreeView
SelectedItemChanged="treeView1_SelectedItemChanged"
HorizontalContentAlignment="Stretch">
<TreeViewItem Header="Intution Studio" ItemsSource="{Binding Main}">
<TreeViewItem.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</TreeViewItem.ItemContainerStyle>
<TreeViewItem.ContextMenu>
<ContextMenu ItemsSource="{Binding}">
<MenuItem Command="Copy">
<!-- (can't enable copy option) -->
<MenuItem.Icon>
<Image Source="Images\copy.png" Width="20" Height="20"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</TreeViewItem.ContextMenu>
<TreeViewItem.Resources>
<HierarchicalDataTemplate DataType="{x:Type TextBlock}">
<!-- ... -->
</HierarchicalDataTemplate>
</TreeViewItem.Resources>
</TreeViewItem>
</TreeView>