But when I cha...">

WPF - style setter property binding

It works.

<Setter Property="Width" Value="300" /> <Setter Property="Height" Value="300" /> 

But when I change this, it doesn’t work.

  <Setter Property="Width" Value="{Binding ImageSize, Mode=TwoWay}" /> <Setter Property="Height" Value="{Binding ImageSize, Mode=TwoWay}" /> 

and declare

  private Int32 imageSize; public Int32 ImageSize { get { return imageSize; } set { imageSize = value; NotifyPropertyChanged("ImageSize"); } } 

What's wrong?

+4
source share
1 answer

The most likely cause is a binding problem, namely a DataContext . I would recommend looking in the Output window for binding errors (they will not be displayed as standard exceptions, but will be displayed in the Output window for debugging purposes). Binding errors should point you in the right direction as far as WPF recognizes it as a DataContext .

+6
source

Source: https://habr.com/ru/post/1484064/