0
我想創建TextBlock的TextChanged事件處理程序使用WindowsstoreApp(WPF)中的自定義依賴屬性,事件沒有被解僱,我不知道我錯了哪裏,請指導我,我已經嘗試到目前爲止,爲文本塊創建事件
public sealed partial class BuyerInput : Page
{
public BuyerInput()
{
this.InitializeComponent();
MyTextblock.SetBinding(MyTextProperty, new Binding { Source = MyTextblock.Text,Path = new PropertyPath("MyText") });
}
public static readonly DependencyProperty MyTextProperty = DependencyProperty.Register("MyText", typeof(BuyerInput), typeof(string), new PropertyMetadata(null, OnMyTextChanged));
public static void OnMyTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//this event is not getting fired whenever the value is changed in TextBlock(MyTextblock)
}
}
感謝您的答案,但我無法在WindowsStoreApp中找到FrameworkPropertyMetadata。 – DesertRiver
哦,所以用你的PropertyChangeCallback和其他改變。那可行。您必須在綁定時設置「Mode = TwoWay」。 –
您能否詳細解釋一下PropertyChangeCallback? – DesertRiver