一個dataGrid
通常用於顯示項目的列表,有幾個特性,你的情況是這樣的代碼:
public class Item
{
public String Result1 { get; set; }
public String Result2 { get; set; }
public String Result3 { get; set; }
}
綁定集合
public ObservableCollection<Item> ListOfResultItems { get; set; }
並且每個屬性都綁定到它的corespon丁柱
<DataGrid Grid.Row="0" x:Name="table" AutoGenerateColumns="False" ItemsSource="{Binding ListOfResultItems}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Result1}" Header="Result1" Width="*">
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Result2}" Header="Result2" Width="*">
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Result3}" Header="Result2" Width="*">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
如果你想顯示三個列表旁邊對方的話,我認爲,一個簡單的
DataGrid
是不是你最好的拍攝
,我建議你定義三個單列的DataGrid
S或ListView
S,結合每個List到相應的列表,並根據您的需要,鏈接他們的垂直滾動或不。
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="0" AutoGenerateColumns="False" ItemsSource="{Binding ListResult1}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="Result1" Width="*">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<DataGrid Grid.Column="1" AutoGenerateColumns="False" ItemsSource="{Binding ListResult2}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="Result2" Width="*">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<DataGrid Grid.Column="2" AutoGenerateColumns="False" ItemsSource="{Binding ListResult3}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="Result3" Width="*">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
和你取得的成果類和定義集合
public ObservableCollection<Result1> ListResult1 { get; set; }
public ObservableCollection<Result2> ListResult2 { get; set; }
public ObservableCollection<Result3> ListResult3 { get; set; }