1

我在另一个 Grid 中有一个 Grid 并将第二个 Grid 添加到 ScrollViewer 但看不到它的滚动条。我添加的 ScrollViewer 网格的名称为InfoGrid。我不明白为什么 ScrollViewer 不起作用。你有什么替代方法可以建议我吗?我的所有窗口的 xaml 代码:

<Window x:Class="ModelView.KillCardCheck"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="Auto" Height="Auto" SizeToContent="WidthAndHeight"
        ResizeMode="NoResize" Icon="pack://application:,,,/Resources/image/ffdc_gui.png"
        xmlns:lex="http://schemas.root-project.org/xaml/presentation" Closing="WindowClosing">

    <Grid Style="{DynamicResource GridStyle}" HorizontalAlignment="Stretch" 
VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="12"/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="11"/>
            <ColumnDefinition Width="109"/>
            <ColumnDefinition Width="250"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>
        <DataGrid Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="2" Style="{DynamicResource {x:Type DataGrid}}"
                      AutoGenerateColumns="False" CanUserSortColumns="False"  CanUserAddRows="False"
                      Margin="4,4,4,4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RowHeight="25" Name="dgKillCardChecks" 
                                  SelectionMode="Single" BorderThickness="1,1,1,0">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Number}" 
                                Width="30" IsReadOnly="True">
                </DataGridTextColumn>
                <DataGridTemplateColumn Header="{lex:LocText Key=check_list, Dict=language, Assembly=FfdcLocalization}" Width="*" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Name="chkCheckList" Content="{Binding CheckItem}"
                                                  Click="CheckListCheckBoxOnClick"
                                              Tag="{Binding Index}"
                                                  IsChecked="{Binding Path=CheckStatus, UpdateSourceTrigger=PropertyChanged}"
                                                  IsHitTestVisible="{Binding Enabled}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>

        </DataGrid>
        <ScrollViewer VerticalScrollBarVisibility="Visible">
            <Grid Style="{DynamicResource GridStyle}" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Margin="4,4,4,4" Name="InfoGrid" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            </Grid>
         </ScrollViewer>
        <TextBlock Name="descriptionBlock" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Margin="4,4,4,4"></TextBlock>
        <Button Style="{DynamicResource {x:Type Button}}" Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="1" 
                    x:Name="btnQuit" MaxHeight="30" Margin="2,4,0,6" MaxWidth="120" MinWidth="80"
                    Content="{lex:LocText Key=close, Dict=language, Assembly=FfdcLocalization}"
                    VerticalContentAlignment="Center" MinHeight="30" VerticalAlignment="Center" HorizontalAlignment="Left" Click="CloseClick"/>
        <Button Style="{DynamicResource {x:Type Button}}" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" 
                    x:Name="btnClear" MaxHeight="30" Margin="2,4,0,6" MaxWidth="200" MinWidth="80"
                    Content="{lex:LocText Key=clear_killcard, Dict=language, Assembly=FfdcLocalization}"
                    VerticalContentAlignment="Center" MinHeight="30" VerticalAlignment="Center" HorizontalAlignment="Right" Click="ClearKillCardClick"/>
    </Grid>

</Window>
4

1 回答 1

0

您制作的 ScrollViewer 没有设置 grid.Row,而是将其放在其中的网格上。这没有多大意义,因为网格(“信息网格”)位于 ScrollViewer 内部,因此它的父级是 ScrollViewer。您可能想尝试设置 ScrollViewer 行和列。

于 2019-09-23T14:04:11.187 回答