1

I have ListView and I want the last item in the row displayed below the actual row items. Raw copy of xaml:

<ListView x:Name="ListViewRotations" FontFamily="Consolas" MouseDoubleClick="ListViewRotations_MouseDoubleClick">
        <ListView.ContextMenu>
            <ContextMenu>
                <MenuItem Header="Remove" Click="ContextMenuItemRemoveClicked" />
            </ContextMenu>
        </ListView.ContextMenu>
        <ListView.View>
            <GridView>
                <GridViewColumn Width="120" Header="Max Craftsmanship" DisplayMemberBinding="{Binding RotationInfo.MaxCraftsmanship}" />
                <GridViewColumn Width="120" Header="Min Craftsmanship" DisplayMemberBinding="{Binding RotationInfo.MinCraftsmanship}" />
                <GridViewColumn Width="80" Header="Min Control" DisplayMemberBinding="{Binding RotationInfo.MinControl}" />
                <GridViewColumn Width="50" Header="CP" DisplayMemberBinding="{Binding RotationInfo.CP}" />
                <GridViewColumn Width="130" Header="Score" DisplayMemberBinding="{Binding RotationInfo.Score}" />
                <GridViewColumn Width ="Auto" Header="Rotation Time" DisplayMemberBinding="{Binding RotationInfo.RotationTime}" />
                <GridViewColumn Width ="Auto" Header="Rotation" >
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <ListBox ItemsSource="{Binding Images}">
                                <ListBox.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Horizontal" />
                                    </ItemsPanelTemplate>
                                </ListBox.ItemsPanel>
                                <ListBox.ItemContainerStyle>
                                    <Style TargetType="ListBoxItem">
                                        <Setter Property="BorderThickness" Value="1"/>
                                        <Setter Property="Margin" Value="0"/>
                                        <Setter Property="Padding" Value="0"/>
                                    </Style>
                                </ListBox.ItemContainerStyle>
                                <ListBox.ItemTemplate>
                                    <DataTemplate DataType="CraftingActionContainer">
                                        <Grid Height="25">
                                            <Image Width="25" Height="25" Source ="{Binding BitmapSource}"  VerticalAlignment="Top" />
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>

As you can see, last item is actually a ListBox and since it is quite long I want it to appear on new line. So far I only thought of creating 2 types of items, one with text data and the other for holding the last item and using template selector. Maybe you know of other ways. Thanks in advance.

Edit: Images included.

Current result

Wanted result

Generally speaking, is it possible to separate last item from row and modify it so it appears below other items

2
  • Hello, it's a little unclear exactly what positioning you want to achieve in the XAML. Can you include a diagram or picture of how it looks now and then describe how you want it to look more clearly? Also, it helps if you have a specific question rather than just "I want it to look like this, how?" Instead try to ask a question like "How do I split up the presentation of a single grid item", or "How do I add a line break in a grid row?" Commented Apr 9, 2020 at 13:31
  • 1
    Edited question by adding images and clarified problem Commented Apr 9, 2020 at 13:57

1 Answer 1

1

You can use DataGrid with row details;

<Grid Margin="10">
    <DataGrid Name="dgUsers" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
            <DataGridTextColumn Header="Birthday" Binding="{Binding Birthday}" />
        </DataGrid.Columns>
        <DataGrid.RowDetailsTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Details}" Margin="10" />
            </DataTemplate>
        </DataGrid.RowDetailsTemplate>
    </DataGrid>
</Grid>

Full tutorial you can find here: Row Details

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer is exactly what I was looking for. Never knew about DataGrid before. Changed source code to use DataGrid and it actually solved another problem too: sorting items when clicking on header, thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.