如何更改Datagrid滚动条的大小

如何更改Datagrid滚动条的大小

本文介绍了如何更改Datagrid滚动条的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Datagrid,它在运行时中显示数据,并且由于它具有大量数据,它本身在其上带有滚动条,但是尺寸较小.谁能告诉我如何更改滚动条的大小并使之变大?

I have a Datagrid that displays the data on Runtime, and as it has lot of data it itself brings scrollbar on it, but the size is smaller. Can anyone tell how to change size of scrollbar and make it bigger ?

<DataGrid x:Name="DgUnitVerReefer" HorizontalAlignment="Center" SelectionMode="Single"      SelectionUnit="FullRow" Margin="20,94,26,0" IsReadOnly="True" AutoGenerateColumns="False"     Visibility="Visible" VerticalAlignment="Top" Height="334"      HorizontalGridLinesBrush="#FFA4C4EA" FontFamily="Microsoft New Tai Lue" AlternatingRowBackground="#FFA4C4EA" MouseDoubleClick="DgUnitVerReefer_MouseDoubleClick" FontSize="16" Width="387">
        <DataGrid.Columns>
            <DataGridTextColumn Header="" Binding="{Binding Path= UNIT_NUMBER}" Width="350" />
        </DataGrid.Columns>
</DataGrid>

然后在window_load中加载数据并分配给datagrid.

and then on window_loaded in load data and assign to datagrid.

   DgUnitVerReefer.DataContext = objVerifyUnit.DtLovReefer.DefaultView;
   DgUnitVerReefer.ItemsSource = objVerifyUnit.DtLovReefer.DefaultView;
   DgUnitVerReefer.DisplayMemberPath = "UNIT_NUMBER";
   DgUnitVerReefer.SelectedValuePath = "UNI_ID";

在运行它时,会显示较小的滚动条,如何更改其大小?

on running it display scrollbar with smaller size, how to change its size ?

推荐答案

您可以在 DataGrid 级别为 ScrollBar 类型应用样式.我们应该对 Orientation 属性使用 Trigger 来将样式仅应用于垂直滚动条:

You can apply style for the ScrollBar type at the DataGrid level. We should use a Trigger against the Orientation property to apply style to the vertical scrollbar only:

<DataGrid.Resources>
    <Style TargetType="ScrollBar">
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="50"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</DataGrid.Resources>

对于水平滚动条,我们需要设置 Height ,而触发器的 Value Horizo​​ntal .

For horizontal scrollbar, we need to set the Height instead, and the Value for the trigger is Horizontal.

这篇关于如何更改Datagrid滚动条的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:16