WPF MVVM TreeView 实现 右键选中 右键菜单

1.非MVVM模式:下载源代码WpfApplication1.zip 

<TreeView Height="200" PreviewMouseRightButtonDown="TreeViewItem_PreviewMouseRightButtonDown" HorizontalAlignment="Left" Margin="12,0,0,0" Name="treeView1" VerticalAlignment="Top" Width="120">
            <TreeViewItem Header="哈哈">
                <TreeViewItem Header="呵呵"/>
                <TreeViewItem Header="嘿嘿" />
                <TreeViewItem Header="哈哈哈哈" />
            TreeViewItem>
            <TreeViewItem Header="呵呵">
                <TreeViewItem Header="呵呵呵呵" />
                <TreeViewItem Header="呵呵呵呵呵呵" />
            TreeViewItem>
            <TreeView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="点我"<

你可能感兴趣的:(数据库,c#)