how to bind width of child element to width of parent element in silverlight how to bind width of child element to width of parent element in silverlight wpf wpf

how to bind width of child element to width of parent element in silverlight


This will actually help you I guess

Width="{Binding ActualWidth, ElementName=parentElementName}"

This binds the width to the parent element or the element name provided


This is generic solution which may work everywhere. You wouldn't need to write parent element name. This will identify its parent and will take parent's width.

Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"


I think that easiest way to do same thing is:

HorizontalAlignment="Stretch"

That is not using binding as you have been asked, but it is easier.