【发布时间】:2010-12-26 10:59:51
【问题描述】:
我正在尝试将一个依赖属性从我的 UserControl 绑定到我的 MainViewModel。
这是 DependencyProperty 的样子:
public static DependencyProperty ItemHasChangesProperty = DependencyProperty.Register("ItemHasChanges",
typeof(bool),
typeof(MyUserControl),
new PropertyMetadata(null));
public bool ItemHasChanges
{
get { return (bool)GetValue(ItemHasChangesProperty); }
set { SetValue(ItemHasChangesProperty, value); }
}
我的 XAML:
<local:MyUserControl ItemHasChanges="{Binding Path=Changes}" Grid.Row="4" />
现在在调试和检查 bool Changes 的 Set-Accessor 时,我发现当我在 UserControl ItemHasChanges = true; 中设置时它永远不会被访问
知道我在这里做错了什么吗?
谢谢!
干杯
【问题讨论】:
标签: c# wpf dependency-properties dependencies