Dwukierunkowe wiązanie w AvalonEdit nie działa
Użyłem AvalonEdit w moim projekcie opartym na WPF i MVVM. Po przeczytaniuten post Stworzyłem następującą klasę:
public class MvvmTextEditor : TextEditor, INotifyPropertyChanged
{
public static DependencyProperty DocumentTextProperty =
DependencyProperty.Register("DocumentText",
typeof(string), typeof(MvvmTextEditor),
new PropertyMetadata((obj, args) =>
{
MvvmTextEditor target = (MvvmTextEditor)obj;
target.DocumentText = (string)args.NewValue;
})
);
public string DocumentText
{
get { return base.Text; }
set { base.Text = value; }
}
protected override void OnTextChanged(EventArgs e)
{
RaisePropertyChanged("DocumentText");
base.OnTextChanged(e);
}
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
i użyłem następującego XAML do użycia tej kontroli:
<avalonedit:MvvmTextEditor x:Name="xmlMessage">
<avalonedit:MvvmTextEditor.DocumentText>
<Binding Path ="MessageXml" Mode="TwoWay"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:XMLMessageValidationRule />
</Binding.ValidationRules>
</Binding>
</avalonedit:MvvmTextEditor.DocumentText>
</avalonedit:MvvmTextEditor>
ale oprawa działaOneWay
i nie aktualizuje mojej właściwości ciągu ani nie uruchamia reguły sprawdzania poprawności.
Jak mogę naprawić wiązanie, aby działało zgodnie z oczekiwaniamiTwoWay
?