Truth be told, I think the easiest way to do this would be to create a custom ItemsPanel
which inherited from WrapGrid
, but added a property to do this (upon item selected, show the assigned ContentTemplate
in a row/column which spans the width/height of the grid closest to the center).
How can I add a control to a GridView when an item is selected such that the control is on the row below the selected item and spans all the columns?
-
11-07-2023 - |
Domanda
I have a GridView with a horizontal orientation.
When the user selects an item in the GridView I would like to show a list (of child objects) between the row of the selected item and the row below the selected item. The list should span all the columns of the GridView.
<GridView ItemsSource="{Binding SrGroups}" ItemTemplate="{StaticResource ServiceReviewGroupTemplate}" ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Auto">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal"></WrapGrid>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
<DataTemplate x:Key="ServiceReviewGroupTemplate">
<Grid Background="{StaticResource BlueMedium}" Height="150" Width="150">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Margin="10,0,10,10" Text="{Binding Name}" />
<TextBlock Grid.Row="1" Margin="10,0,10,10">
<Run Text="{Binding SrInstances.Count, Mode=OneWay}"/>
<Run Text="Instances" />
</TextBlock>
</Grid>
</DataTemplate>
Soluzione
Altri suggerimenti
How many items will you be displaying in the sub list? I don't think your GridView will look uniformed. What you can do is bind a ListView to your GridViewItem Data Template. Check out Microsoft's WinRT Sample Code. It should have a multi-list GridView Sample or point you in the right direction.
Best of Luck
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow