binding to width property in code behind

后端 未结 2 1087
一整个雨季
一整个雨季 2020-12-19 10:17

I have a situation where I need to create View box with one button. The xaml for this is as below: Please observe Width property of viewbox. The Width should be increased/de

2条回答
  •  借酒劲吻你
    2020-12-19 10:33

    This should do what you want:

    Viewbox x = new Viewbox();
    Binding bnd = new Binding("Value") { ElementName = "ZoomSlider"};
    BindingOperations.SetBinding(x, Viewbox.WidthProperty, bnd);
    // ... Code to insert the Viewbox into the WrapPanel etc.
    

提交回复
热议问题