WPF-无限的数据网格高度

时间:2019-07-03 08:49:22

标签: c# wpf

我使用的是Syncfusion的SfDataGrid而不是标准的SfDataGrid,但是我想这个问题更多的是关于XAML,而不是控件本身。

因此,我有一个带有DataGrid的窗口。例如,如果有60条记录,则窗口会变得很高。我希望窗口完全不更改其大小。而且真的不知道为什么会这样。

这是我的XAML:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    <Grid Grid.Column="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Margin="10,0,10,0" Grid.Row="0" DataContext="{Binding Info}">
            <TextBlock Text="Amount:"/>
            <sf:CurrencyTextBox Value="{Binding Amount}" Margin="0,0,0,10"/>
            <!-- some other controls -->

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource LeftLabel}"
                           Text="Count:"/>
                <sf:UpDown Grid.Column="1" Grid.Row="0" Margin="0,0,0,5"
                           Value="{Binding Count}"/>

                <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource LeftLabel}"
                           Text="Year count:"/>
                <sf:UpDown Grid.Column="1" Grid.Row="1" 
                           Value="{Binding YearCount}"/>
            </Grid>

        </StackPanel>

        <Button Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,5" 
                Content="Simulate >>"
                Command="{Binding SimulateCommand}"/>
    </Grid>

<!-- This is right part of the window with datagrid -->
    <DockPanel Grid.Column="1">
        <WrapPanel DockPanel.Dock="Top">
            <TextBlock Margin="10" Text="Total amount:" />
            <TextBlock Text="{Binding TotalAmount"/>
        </WrapPanel>

<!-- and the datagrid -->
        <sf:SfDataGrid AutoGenerateColumns="False"
                       AllowDeleting="False"
                       AllowEditing="False"
                       IsReadOnly="False"
                       AllowGrouping="False"
                       AllowFiltering="False"
                       ItemsSource="{Binding History}">
            <sf:SfDataGrid.Columns>
                <sf:GridDateTimeColumn DisplayBinding="{Binding Date}" MappingName="PaymentDay" HeaderText="Date"/>
                <sf:GridCurrencyColumn DisplayBinding="{Binding Amount}" MappingName="PayAmount" HeaderText="Amount"/>
            </sf:SfDataGrid.Columns>
        </sf:SfDataGrid>

    </DockPanel>        
</Grid>

那有什么问题呢?

0 个答案:

没有答案