I've created a custom user control named MyCustomComboBox. Everywhere in the application I put it I do the following:
<Widgets:MyCustomComboBox
Foo="{Binding Foo,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
MyCustomComboxBox has the dependency property Foo, I have some validation and other logic in the combobox which is the very reason why I wrapped it up in a custom control.
The custom combobox is included another user control which also has a Foo property, which the combobox's is bound to.
But I also have to set UpdateSourceTrigger and Mode, I would like to somehow specify that those are the default values when binding to that DependencyProperty. Can it be done?
The default BindingMode can be specified in the dependency property metadata:
public static readonly DependencyProperty FooProperty = DependencyProperty.Register(
"Foo",
typeof(string),
typeof(MyCustomComboBox),
new FrameworkPropertyMetadata(
null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault);
However, to my knowledge there is no way to provide a default for the update source trigger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With