मैंने अपनी परियोजना में AvalonEdit का उपयोग किया है जो WPF और MVVM पर आधारित है। this post पढ़ने के बाद मैं निम्नलिखित श्रेणी का निर्माण:AvalonEdit में दो-तरफा बाध्यकारी काम नहीं करता
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));
}
}
}
और इस पर नियंत्रण का उपयोग करने के लिए निम्न XAML प्रयोग किया है:
<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>
लेकिन बाध्यकारी काम करता है OneWay
और मेरे स्ट्रिंग संपत्ति है और न ही चलाने सत्यापन अपडेट नहीं करता राज करते हैं।
मैं TwoWay
के रूप में काम करने के लिए बाध्यकारी कैसे ठीक कर सकता हूं?
क्या आप कृपया मुझे बता सकते हैं कि यह कैसे काम कर रहा है? मैंने एक और सवाल पूछा है [यहां] (http://stackoverflow.com/questions/18964176/two-way-binding-to-avalonedit-document-text-using-mvvm?noredirect=1#comment28010773_18964176) ... – MoonKnight