I have a Border inside a Canvas. The Border’s height/width are varying according to its contents. I want the Border to stretch out to fill up the entire Canvas. How can I do that?
I have tried this on the Border without success:
Height='{Binding ElementName=MainCanvas, Path=Height}' Width='{Binding ElementName=MainCanvas, Path=Width}'
Does the canvas have an explicit height/width? It may be auto sizing and have a height/width of double.NaN.
Try binding the child height/width to the ActualHeight and ActualWidth of canvas like so:
Canvas Panels never tell children to size relative to their size, even when the children are set to HorizontalAlignment.Stretch (or vertical). So binding is a good solution here.