2010-01-22 6 views
1

J'ai un contrôle d'édition hautement personnalisé qui hérite RichTextBox. J'avais besoin d'un moyen de lier un Value à ce contrôle, donc j'ai enregistré un nouveau DependencyProperty, mais j'ai du mal à le coder comme j'ai besoin.DependencyProperty avec la liaison TwoWay

public static readonly DependencyProperty ValueProperty = 
      DependencyProperty.Register("Value", typeof(string), typeof(XliffRichCellEditor), 
      new PropertyMetadata(new PropertyChangedCallback(XliffRichCellEditor.OnValuePropertyChanged))); 
public String Value 
{ 
    get { return (String)this.GetValue(ValueProperty); } 
    set { this.SetValue(ValueProperty, value); } 
} 

private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
{ 
    // Need to change Document in RichTextBox when Binding Source is changed 
    // But also ignore if the change comes from RichTextBox which is only updating 
    // the DependencyProperty. In this case Binding Source should be updated. 
} 

Aidez-nous s'il vous plaît.

Répondre

0

l'utilisation peut utiliser UpdateSourceTrigger=Explicit dans votre instruction Binding et obtenir le contrôle de la mise à jour des propriétés dans votre main.

Cochez cette case Thread

Questions connexes