我有一个绑定到属性的TextBox。有没有办法在不使用
的情况下更新textBox的内容RaisePropertyChanged(() => Property);
在房产内?
我想在另一个Property2中更新Property1的值,然后更新绑定到Property2内的Property1的TextBox的值。
这可能吗?
答案 0 :(得分:1)
我相信您可能正在寻找PropertyChangedCallback。
基本的sentax是这样的:
static ClassName()
{
Property = DependencyProperty.Register("PropertyName", typeof(propertyType), typeof(ownerType),
new UIPropertyMetadata(new PropertyChangedCallback(PropertyChangedCallback));
}
static void PropertyChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArts e)
{
ClassName class = obj as ClassName;
// Manipulate properties by accessing them through class.
}
static ClassName()
{
Property = DependencyProperty.Register("PropertyName", typeof(propertyType), typeof(ownerType),
new UIPropertyMetadata(new PropertyChangedCallback(PropertyChangedCallback));
}
static void PropertyChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArts e)
{
ClassName class = obj as ClassName;
// Manipulate properties by accessing them through class.
}
有关更多信息,请参阅此链接: http://msdn.microsoft.com/en-us/library/ms745795.aspx