簡體   English   中英

水平滾動條不起作用Datagrid

[英]Horizontal Scroll Bar isn't working Datagrid

對於我在我的應用程序中使用的所有其他Datagrids正常工作但由於某種原因,這個沒有。

我希望我的Datagrid水平滾動條在數據變大時出現,但它只是擴展整個Datagrid。

我只需要顯示水平滾動條,這些是我為使其工作所做的一些事情。

<DataGrid x:Name="dgAllocate" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" ItemsSource="{Binding}" Foreground="white" BorderBrush="Black" CanUserResizeRows="False" ScrollViewer.CanContentScroll="True" RowHeaderWidth="0" RowHeight="25" AutoGenerateColumns="False" TextBlock.TextAlignment="Center" Margin="26,84,687,91" Style="{x:Null}" Background="#FF616972" FontFamily="Malgun Gothic" AlternationCount="2" GridLinesVisibility="None" CanUserAddRows="False" FontSize="10">

可以回顧一下XAML並告訴我我做錯了什么。

<Page x:Class="Freeway_Audit_Application.AllocateAudits"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  mc:Ignorable="d" 
  d:DesignHeight="820" d:DesignWidth="1245"
Title="AllocateAudits">
<Grid Background="White">
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <!--Title of the datagrid-->
    <Label Content="Select Your Transaction" HorizontalAlignment="Left" Margin="20,58,0,0" VerticalAlignment="Top" FontFamily="Malgun Gothic" FontSize="15" Foreground="Black" Width="321"/>

    <!--Title of the invisable datagrid-->
    <Label Content="Users To-Do-List" HorizontalAlignment="Left" Margin="702,60,0,0" VerticalAlignment="Top" FontFamily="Malgun Gothic" FontSize="15" Foreground="Black" Width="216"/>


<DataGrid x:Name="dgAllocate" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="T" ItemsSource="{Binding}" Foreground="white" BorderBrush="Black" CanUserResizeRows="False" ScrollViewer.CanContentScroll="True" RowHeaderWidth="0" RowHeight="25" AutoGenerateColumns="False" TextBlock.TextAlignment="Center" Margin="26,84,687,91" Style="{x:Null}" Background="#FF616972" FontFamily="Malgun Gothic" AlternationCount="2" GridLinesVisibility="None" CanUserAddRows="False" FontSize="10">
        <DataGrid.RowStyle>
            <Style TargetType="{x:Type DataGridRow}">
                <Style.Triggers>
                    <Trigger Property="AlternationIndex" Value="0">
                        <Setter Property="Background" Value="#FF616972" />
                    </Trigger>
                    <Trigger Property="AlternationIndex" Value="1">
                        <Setter Property="Background" Value="#FF585F66" />
                    </Trigger>
                    <DataTrigger Binding="{Binding Selectable}" Value="False">
                        <Setter Property="Background" Value="LightGray" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </DataGrid.RowStyle>
        <DataGrid.ColumnHeaderStyle>
            <Style TargetType="{x:Type DataGridColumnHeader}">
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="BorderBrush" Value="Black"/>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="FontSize" Value="10"/>
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
                            <GradientStop Color="#FF4B525A" Offset="1.0"/>
                            <GradientStop Color="#FF343841" Offset="0.0"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="White"/>
            </Style>
        </DataGrid.ColumnHeaderStyle>
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding AAAA}" ClipboardContentBinding="{x:Null}" Header="AAAA" Width="*" Visibility="Hidden"/>
            <DataGridTextColumn Binding="{Binding BBBB}" ClipboardContentBinding="{x:Null}" Header="BBBB" Width="*" Visibility="Hidden"/>
            <DataGridTextColumn Binding="{Binding CCCC}" ClipboardContentBinding="{x:Null}" Header="CCCC" Width="*" Visibility="Hidden"/>
            <DataGridTextColumn Binding="{Binding DDDD}" ClipboardContentBinding="{x:Null}" Header="DDDD " Width="*"/>
            <DataGridTextColumn Binding="{Binding EEEE}" ClipboardContentBinding="{x:Null}" Header="EEEE" Width="*"/>
            <DataGridTextColumn Binding="{Binding FFFF}" ClipboardContentBinding="{x:Null}" Header="FFFF" Width="*"/>
            <DataGridTextColumn Binding="{Binding GGGG}" ClipboardContentBinding="{x:Null}" Header="GGGG" Width="*"/>
            <DataGridTextColumn Binding="{Binding HHHH}" ClipboardContentBinding="{x:Null}" Header="HHHH" Width="*"/>
            <DataGridTextColumn Binding="{Binding IIII}" ClipboardContentBinding="{x:Null}" Header="IIII" Width="*" Visibility="Hidden"/>
            <DataGridTextColumn Binding="{Binding JJJJ}" ClipboardContentBinding="{x:Null}" Header="JJJJ" Width="*"/>
            <DataGridTextColumn Binding="{Binding KKKK}" ClipboardContentBinding="{x:Null}" Header="KKKK" Width="*" Visibility="Hidden"/>
            <DataGridTextColumn Binding="{Binding LLLL}" ClipboardContentBinding="{x:Null}" Header="LLLL" Visibility="Hidden" Width="*"/>
        </DataGrid.Columns>
    </DataGrid>

HorizontalScrollBarVisibility="Auto"而不是嘗試HorizontalScrollBarVisibility="Visible"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM