0

我得到的图层如下:

<Window>
  <Grid>
     <Scrollviewer>
        <Canvas>
          ....
        <Canvas/>
     <Scrollviewer/>
  <Grid/>
<Window/>

现在,如果我希望我的网格扩展并遵循窗口的高度和宽度,我使用以下代码:

<Window Title="MainWindow" Name="Window" MinHeight="500" MinWidth="800">

<Grid Height="{Binding ElementName=Window, Path=Height}" Width="{Binding ElementName=Window, Path=Width}" x:Name="theGrid">
    <Grid.RowDefinitions>
        <RowDefinition Height="436*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,50,15,66">
        <Canvas MinWidth="{Binding ElementName=theGrid, Path=Width}" MinHeight="{Binding ElementName=theGrid, Path=Height}" Name="canvas1">
                <Canvas.LayoutTransform>
                    <ScaleTransform ScaleX="{Binding Path=Value, ElementName=slider1}"
                                    ScaleY="{Binding Path=Value, ElementName=slider1}"/>
                </Canvas.LayoutTransform>
            </Canvas>
    </ScrollViewer>

当我通过拉窗口的边/角来调整窗口大小时,这很好用..!但是!当我点击右上角的“全屏”按钮时,它只显示最后一张图片网格的网格大小。像这样:

网格在窗口的中间

就像它在“全屏”后不会重新绘制网格一样......帮帮我?

4

1 回答 1

0

您明确设置网格的Width和是否有特定原因?Height将网格设置Margin为 0 将始终将 Grid 设置为窗口大小

    <Grid Margin="0" x:Name="theGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="436*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

 <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,50,15,66">
        <Canvas Margin="0" Name="canvas1">
                <Canvas.LayoutTransform>
                    <ScaleTransform ScaleX="{Binding Path=Value, ElementName=slider1}"
                                    ScaleY="{Binding Path=Value, ElementName=slider1}"/>
                </Canvas.LayoutTransform>
            </Canvas>
    </ScrollViewer>
于 2012-12-10T22:40:08.870 回答