我的装订有问题,让我很困惑。每当我第一次设置我的 Building 属性时,我的 TitleRasedText
对象的文本都会设置为我所期望的。但是,当我为 Building 属性设置新值时,Title 对象的文本字段仍然保持旧值。有什么想法为什么?
public static readonly DependencyProperty buildingProperty = DependencyProperty.Register
(
"building",
typeof(string),
typeof(FloorPlan),
new PropertyMetadata((d,e) =>
{
try
{
(d as FloorPlan).BuildingChanged();
} catch {}
}
));
public string Building
{
get { return (string)GetValue(buildingProperty); }
set { SetValue(buildingProperty, value); }
}
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
//Code...
Binding binding = new Binding();
binding.Source = Building;
binding.Mode = BindingMode.OneWay;
Title.SetBinding(TextControls.RaisedText.TextProperty, binding);
//Code...
}