1
有沒有辦法將我的自定義DependencyProperty的ValidatesOnDataErrors設置爲True,所以我不必每次綁定到它時都這樣做? this的內容。有沒有辦法指定一個自定義依賴屬性的默認ValidatesOnDataErrors?
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string),
typeof(ErrorTextEdit), new FrameworkPropertyMetadata(null)
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
// Something Here maybe???
});
public string Text
{
get { return (string) GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
我的控件也可以從TextBox繼承,如果有幫助的話。
這是一個非常優雅的做法,我沒有考慮過。 – gajo357