I'm trying to bind a Dependency Property from my UserControl to my MainViewModel.
This is how the DependencyProperty looks like:
public static DependencyProperty ItemHasChangesProperty = DependencyProperty.Register("ItemHasChanges",
typeof(bool),
typeof(MyUserControl),
new PropertyMetadata(null));
public bool ItemHasChanges
{
get { return (bool)GetValue(ItemHasChangesProperty); }
set { SetValue(ItemHasChangesProperty, value); }
}
My XAML:
<local:MyUserControl ItemHasChanges="{Binding Path=Changes}" Grid.Row="4" />
Now when debugging and checking the Set-Accessor of bool Changes
, I see that it never gets accessed when I set in the UserControl ItemHasChanges = true;
Any idea what I'm doing wrong here?
Thanks!
Cheers
Got it.. I had to change
<local:MyUserControl ItemHasChanges="{Binding Path=Changes}" Grid.Row="4" />
to
<local:MyUserControl ItemHasChanges="{Binding Path=Changes, Mode=OneWayToSource}" Grid.Row="4" />
Took me about 3h to figure it out.. haha :-)
Cheers
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