我有以下 UserControl,里面有两个 DataGrid:
<UserControl x:Class="emb.OrdersControl"
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="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200*" />
<RowDefinition Height="100*" />
</Grid.RowDefinitions>
<DataGrid AutoGenerateColumns="True" Name="dgSell" IsReadOnly="True" CanUserResizeRows="False"></DataGrid>
<DataGrid AutoGenerateColumns="True" Grid.Row="1" Name="dgBuy" IsReadOnly="True" CanUserResizeRows="False" />
</Grid>
</UserControl>
我将它们连接到两个数据表:
class Order {
public string station;
public float price;
}
...
foreach (Order order in parse_orders(xml, "sell_orders"))
sell_orders.Rows.Add(new object[] {order.station, order.price});
这是结果:
设置一个固定的高度只会切断 Station 文本的底部。设置对齐没有任何作用。