我有以下带有两个DataGrids的UserControl:
<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>
我将它们连接到两个DataTables:
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文本的底部。设置对齐无效。
答案 0 :(得分:2)
哈。发布后不久就意识到了这一点。
我所加入的文本在解析XML之前和之后都有很多空格和换行符。