I have problem with creating a control which will be king of InPlaceEdit and which will handle validation.
Before I was thinking about validation I have created a control, which has dependency property:
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
"Value",
typeof (object),
typeof (InPlaceEdit),
new FrameworkPropertyMetadata(default (object), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ValueChanged));
And I have additional property for storing local (unchanged) value:
public static readonly DependencyProperty LocalValueProperty = DependencyProperty.Register(
"LocalValue",
typeof (object),
typeof (InPlaceEdit),
new FrameworkPropertyMetadata(default(object), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
I have created buttons Save
and Cancel
which saving 'LocalValue' to binded property on save and restores 'LocalValue' from 'Value' on cancel.
It's working perfectly, but I have one problem with it. It does not support validation, because my binded value is changing on button click.
Is there a way to pass validation from ViewModel to my control somehow?