2010-03-12 20 views
0

您好我有属性命名。检查/取消选中属性已更改的ToolBarButton

public bool ShowLabels{get; set;} 

和一个工具栏菜单按钮,设置/取消ShowLabels重视

我想,当ShowLabels属性的值发生变化,也改变菜单按钮的选中状态。我怎么能做到这一点

回答

0

创建showLabels一个真正的私有变量,并展开get;和是确实的opertation你需要一个方法:

private bool showLabels; 
public bool ShowLabels 
{ 
    get {return this.showLabels; } 
    set { 
     toolbaritem.property = !toolbaritem.property; 
     this.showlabels = value; 
    } 
} 
+0

我也从工具栏项目的点击事件设置ShowLabels的值。 – Mohsan 2010-03-12 13:25:42

+0

这会使用相同的功能 - 你的'ShowLabels = true'会调用这个setter,这会影响复选框。 – cjk 2010-03-12 16:14:54

0

而不是“自动”财产,写您自己的属性访问器来更改菜单按钮的检查状态。

相关问题