I am trying to bing a grid size (i.e. Width and Height) to one of its child (i.e. a Viewbox). I tried this :
Binding bind = new Binding(); bind.Source = this._vb; this._container.SetBinding(Grid.DataContextProperty, bind); But it did not work as expected so I tried this
Binding bindWidth = new Binding(); bindWidth.Source = this._vb.Width; this._container.SetBinding(Grid.WidthProperty, bindWidth); Binding bindHeight = new Binding(); bindHeight.Source = this._vb.Height; this._container.SetBinding(Grid.HeightProperty, bindHeight); I wanted to zoom the Viewbox to have its child zoomed as well and update the Grid parent of my Viewbox. I also tried to do the opposite way (zoom the grid binded to my viewbox but it did not work).
Does someone know why it happens ?