0

I have a static class like this:

static class HelperUpdater
{
    private static double _hwidth = 40d;
    public static double HWidth
    {
        get { return _hwidth; }
        set { _hwidth = value; }
    }
}

and I have a Textbox that text of it bind to HWidth and a Rectangle that width of it bind to HWidth. how can change this project that when changing textbox value then change width of rectangle? Xaml I use is this:

        <Canvas>
        <TextBox Text="{Binding Path=(local:HelperUpdater.HWidth),Mode=TwoWay}" Width="100"/>
        <TextBox Text="" Width="100" Canvas.Top="30"/>
        <Rectangle Stroke="Black" Fill="Red" StrokeThickness="2" Canvas.Left="10" Canvas.Top="100" Height="50"
                   Width="{Binding Path=(local:HelperUpdater.HWidth)}"/>
    </Canvas>
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44
Davoud
  • 17
  • 6
  • Why don't you directly bind one UI element's property to that of the other? The static helper class seems pointless. – Clemens May 06 '20 at 11:30
  • Thanks, I found solution here: https://stackoverflow.com/questions/41823609/notify-binding-for-static-properties-in-static-classes – Davoud May 07 '20 at 08:25

0 Answers0