Copy for Treeview Item in wpf

How to enable copy in my treeviewitem so that i can copy the text in treeview selecteditem and paste it somewhere else. I can't find such property in treeview in wpf.

here is my code

<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>

Answers


Edit: Sorry WPF does not support that.

You should solve this by cloning the underlying data in your model. If you don't have MVVM or must per se clone the visual control, the only reasonable solution seems serializing it to a xaml and then reconstructing it from that.

http://social.msdn.microsoft.com/Forums/en/wpf/thread/209597f0-0e8b-4fbb-a69d-a6479ed96187


Need Your Help

shake screen unlock

android

I am working on an app which will lock the screen on shake it consist of a main activity having two buttons to start and stop the app.

ASP.NET Web API Self-Host both HTTPS and HTTP in single service?

.net asp.net-web-api

I have a public self-hosted ASP.NET Web API service that exposes two controllers. One of them I would like to have accessible only via HTTPS, and the other I don't. Can this be done within a single

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.