3

我在网格中有一个弹出控件,我希望它调整为父网格大小。如您所见,父网格区域为绿色,弹出窗口为 LightCyan 颜色。LightCyan 中的区域应覆盖整个绿色区域。而且我认为我必须将 Scrollviewer 的宽度和高度设置为父级的宽度和高度,但这不起作用。请回复。谢谢

我正在使用代码在 LinePopGrid 中添加不同的东西。

<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>

附图

4

1 回答 1

7

您需要将 PopUpwidthheightGridActualWidth分别绑定到ActualHeight-

<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>
于 2013-03-02T12:37:07.543 回答