【问题标题】:DataGrid's rows appear minisized when the application is run运行应用程序时,DataGrid 的行显示为最小化
【发布时间】:2012-04-22 23:52:54
【问题描述】:

我创建了以下 DataGrid 设计:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:leartWPF" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="leartWPF.Window1"
    x:Name="Window"
    Title="Window1"
    Width="640" Height="480">
    <Window.Resources>
        <local:GroupDataSource x:Key="GroupDataSourceDataSource" d:IsDataSource="True"/>
        <DataTemplate x:Key="GroupCellTemplete" >
            <Grid>
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding }" />
            </Grid>
        </DataTemplate>
    </Window.Resources>

    <Grid x:Name="LayoutRoot" Margin="0" DataContext="{Binding Source={StaticResource GroupDataSourceDataSource}}">
        <DataGrid  Margin="0" HeadersVisibility="None" ItemsSource="{Binding Groups, Mode=OneWay}" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Groups" IsReadOnly="True" CellTemplate="{DynamicResource GroupCellTemplete}"/>
            </DataGrid.Columns>
        </DataGrid>

    </Grid>
</Window>

在 ExpressionBlend 中看起来像这样:

但是,当我运行应用程序时,它看起来像这样:

我做错了什么?

【问题讨论】:

    标签: c# wpf xaml height row


    【解决方案1】:

    试试这个:

    dataGrid.RowHeight = double.NaN;
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-07
    • 1970-01-01
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    相关资源
    最近更新 更多