WPF List, where you can flip out every row and you get more rows under this row
i want a list filled with e.g. cars and when i click on one row, some rows with different开发者_如何学Python shops, where you can buy these cars should be shown under the clicked row.
How can i realize that?
If you use a datagrid, you can set the RowDetailsTemplate that will automatically show the details for the selected row. This is a whole dataGrid, look at the RowDetailsTemplate section. It contains another datagrid for the details.
<Data:DataGrid ItemsSource="{Binding SortedContainers}"
SelectedItem="{Binding CurrentItem, Mode=TwoWay}" AutoGenerateColumns="False"
FrozenColumnCount="0" IsEnabled="True">
<Data:DataGrid.Columns>
<Data:DataGridTextColumn Binding="{Binding Model.Bk_Term}" Header="Terminal" IsReadOnly="True" />
<Data:DataGridTemplateColumn Header="Equip Id">
<Data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Model.Eqp_Id}" VerticalAlignment="Center" IsEnabled="True" IsReadOnly="True"/>
</DataTemplate>
</Data:DataGridTemplateColumn.CellTemplate>
</Data:DataGridTemplateColumn>
<Data:DataGridTextColumn Binding="{Binding Customer}" Header="Owner" IsReadOnly="True" />
<Data:DataGridTextColumn Binding="{Binding Location}" Header="Location" IsReadOnly="True" />
<Data:DataGridTextColumn Binding="{Binding Model.RE059Id}" Header="Id" IsReadOnly="True" />
</Data:DataGrid.Columns>
<Data:DataGrid.RowDetailsTemplate>
<DataTemplate>
<Data:DataGrid ItemsSource="{Binding NoteList.AllItems}" AreRowDetailsFrozen="True" HorizontalAlignment="Stretch"
AutoGenerateColumns="False" FontSize="14" SelectedItem="{Binding Path=CurrentItem, Mode=TwoWay}"
Visibility="{Binding NoteList.AllItems.Count, Converter={StaticResource RowCountVisibilityConverter}}"
RowDetailsVisibilityMode="Visible">
<Data:DataGrid.Columns>
<Data:DataGridTemplateColumn Header="Notes" Width="*">
<Data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Model.Note}"
FontSize="10" Width="Auto" IsReadOnly="{Binding IsReadOnly}"
HorizontalAlignment="Stretch" VerticalAlignment="Center" TextWrapping="Wrap">
</TextBox>
</DataTemplate>
</Data:DataGridTemplateColumn.CellTemplate>
</Data:DataGridTemplateColumn>
</Data:DataGrid.Columns>
</Data:DataGrid>
</DataTemplate>
</Data:DataGrid.RowDetailsTemplate>
</Data:DataGrid>
精彩评论