I have a popup control in a grid and I want it to resize to the parent grid size. As you can see the parent grid area is in Green color and the popup is in LightCyan color. The area in the LightCyan should cover the whole green area. And I think I have to set the Scrollviewer width and height to the parent's width and height but that didn't work. Please reply. Thanks
I am adding different stuff in the LinePopGrid using code.
<Grid Background="Green">
<Popup x:Name="LinePopUp" IsOpen="True" Placement="Relative" >
<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto">
<Grid Background="LightCyan" x:Name="LinePopUpGrid" />
</ScrollViewer>
</Popup>
</Grid>
You need to bind PopUp width
and height
to Grid's ActualWidth
and ActualHeight
respectively -
<Grid Background="Green">
<Popup x:Name="LinePopUp" IsOpen="True" Placement="Relative"
Width="{Binding ActualWidth,RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=Grid}}"
Height="{Binding ActualHeight,RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=Grid}}">
<ScrollViewer CanContentScroll="True"
VerticalScrollBarVisibility="Auto">
<Grid Background="LightCyan" x:Name="LinePopUpGrid" />
</ScrollViewer>
</Popup>
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With