C# 数据网格&x27;当应用程序运行时,s行显示为缩小
我创建了以下DataGrid设计:C# 数据网格&x27;当应用程序运行时,s行显示为缩小,c#,wpf,xaml,height,row,C#,Wpf,Xaml,Height,Row,我创建了以下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/bl
<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中的哪个选项如下所示:
但是,当我运行应用程序时,它看起来是这样的:
我做错了什么?试试这个:
dataGrid.RowHeight = double.NaN;
你知道如何在XAML中设置它吗?看看这里:这里谢谢。还有一个问题:应用程序现在将单元格显示为空,而不是显示内容,即使我在中设置了{Binding Path=.}。我正在尝试将datagrid绑定到字符串列表。你知道这有什么不对吗?