假设我在 WPF UserControl 中有以下代码。我想绑定到Asset.ChildProperty
. 它目前不起作用,因为 Asset 属性更改时我没有收到通知。如何安排事情,以便在 AssetID 更改时触发 Asset 属性的通知?
public static readonly DependencyProperty AssetIdProperty = DependencyProperty.Register("AssetId", typeof(string), typeof(GaugeBaseControl));
[Browsable(false), DataMember]
public string AssetId
{
get { return (string)GetValue(AssetIdProperty); }
set { SetValue(AssetIdProperty, value); }
}
[DisplayName("Asset Item"), Category("Value Binding")]
public AssetViewModel Asset
{
get { return Manager.Models.FirstOrDefault(m => m.Model.UniqueId == AssetId); }
set
{
if (value == null)
AssetId = string.Empty;
else
AssetId = value.Model.UniqueId;
}
}