wpf treeview中动态创建的treeViewItem如何用右键触发菜单?
我从服务器端接收信息并创建TreeViewItem之后,需要右键对这个item进行操作弹出一个菜单,该如何实现?...
我从服务器端接收信息并创建TreeViewItem之后,需要右键对这个item进行操作弹出一个菜单,该如何实现?
展开
2015-08-04 · 知道合伙人数码行家
关注
展开全部
public class ResourcesSettingViewModel : SoftGuidanceViewModelBase
2 {
3 #region Contructor
4 public ResourcesSettingViewModel()
5 : this(new ResourcesSettingModel())
6 {
7
8 }
9 public ResourcesSettingViewModel(ResourcesSettingModel resourcesSettingModel)
10 {
11 this.resourcesSettingModel = resourcesSettingModel;
12
13 }
14 #endregion
15 #region Variables
16
17 private ResourcesSettingModel resourcesSettingModel;
18
19 #endregion
20 #region Properties
21 public ResourcesSettingModel ResourcesSettingModel
22 {
23 get { return this.resourcesSettingModel; }
24 }
25 private EverTreeViewItem selectedTreeViewItem;
26
27
28 public EverTreeViewItem SelectedTreeViewItem
29 {
30 get { return this.selectedTreeViewItem; }
31 set
32 {
33 if (this.selectedTreeViewItem == value)
34 {
35 return;
36 }
37 this.selectedTreeViewItem = value;
38 this.RaisePropertyChanged(() => this.SelectedTreeViewItem);
39 }
40 }
41
42
43 #endregion
44 #region Command
45 public ICommand MenuAddCommand
46 {
47 get
48 {
49 return new DelegateCommand(()=>
50
51 {
52 MessageBox.Show("");
53 });
54 }
55 }
56
57
58
59
60
61 #endregion
62
63 //private EverTreeViewItem GetSelectdTreeViewItem()
64 //{
65 // EverTreeViewItem treeViewItem = (EverTreeViewItem)SelectedTreeViewItem;
66 // return treeViewItem;
67 //}
68 }
2 {
3 #region Contructor
4 public ResourcesSettingViewModel()
5 : this(new ResourcesSettingModel())
6 {
7
8 }
9 public ResourcesSettingViewModel(ResourcesSettingModel resourcesSettingModel)
10 {
11 this.resourcesSettingModel = resourcesSettingModel;
12
13 }
14 #endregion
15 #region Variables
16
17 private ResourcesSettingModel resourcesSettingModel;
18
19 #endregion
20 #region Properties
21 public ResourcesSettingModel ResourcesSettingModel
22 {
23 get { return this.resourcesSettingModel; }
24 }
25 private EverTreeViewItem selectedTreeViewItem;
26
27
28 public EverTreeViewItem SelectedTreeViewItem
29 {
30 get { return this.selectedTreeViewItem; }
31 set
32 {
33 if (this.selectedTreeViewItem == value)
34 {
35 return;
36 }
37 this.selectedTreeViewItem = value;
38 this.RaisePropertyChanged(() => this.SelectedTreeViewItem);
39 }
40 }
41
42
43 #endregion
44 #region Command
45 public ICommand MenuAddCommand
46 {
47 get
48 {
49 return new DelegateCommand(()=>
50
51 {
52 MessageBox.Show("");
53 });
54 }
55 }
56
57
58
59
60
61 #endregion
62
63 //private EverTreeViewItem GetSelectdTreeViewItem()
64 //{
65 // EverTreeViewItem treeViewItem = (EverTreeViewItem)SelectedTreeViewItem;
66 // return treeViewItem;
67 //}
68 }
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
?
追问
?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是MVVM的开发方式么?
更多追问追答
追问
是的,但是我觉得一个单纯的代码实现和开发方式没有多大关系吧。。。额,菜鸟所见。。。
追答
有关系啊。。写的地方不一样~~~~思路也不同~
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询