I try to define the width of a WPF <Frame>
control to the size of its parant (<StackPanel>
which fills the entire window width). For any reason the Frame
element just takes the width of its child and not of its parent. I have googled for many "parent width" solutions (other container controls) but none of the worked with a Frame
. Actually the HorizontalAlignment="Stretch"
setting suppose to make it possible, but it doesn't work.
My code:
<StackPanel Orientation="Horizontal" Background="BlueViolet" HorizontalAlignment="Stretch">
<Frame Background="Yellow" HorizontalAlignment="Stretch" />
</StackPanel>
Any idea how to set the width of a Frame
UI control to its parent?
Update Answer:
It seems that the width setting of a Frame
does not to work in combination with a StackPanel
as parent. When I use a Grid
container instead, then the Frame
width adjusts as expected to the cell width defined in the Grid
.