更新TextBox内容

时间:2012-07-11 21:16:12

标签: c# wpf prism

我有一个绑定到属性的TextBox。有没有办法在不使用

的情况下更新textBox的内容
RaisePropertyChanged(() => Property);

在房产内?

我想在另一个Property2中更新Property1的值,然后更新绑定到Property2内的Property1的TextBox的值。

这可能吗?

1 个答案:

答案 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