I am creating a ListView that should have five columns - the first should have text that can be of any length and should be wrapped whenever the window is resized (in addition to changing the height of the line so that the wrapped text is visible), and the remaining four columns - the static width is 45. I was looking for a watch on this, and every solution that I come across either requires a static width or does not work.
Solutions tried:
Auto column widths, 1 *, 2 *, etc. (parameters are ignored) DockPanel (settings are ignored) WrapPanel (ignored) Set the width in the RelativeSource of the parent for ActualWidth (ignored)
Any ideas? It seems that a significant part of the people had the same problem, but I would prefer that I didn't have to go the static width path for this column. Moreover, the content is simply turned off when I do this (even with height = "Auto" for the line). The width of the whole window can be as high as 1024, but it can also be 1600+, so I want a dynamic size. That way, smaller screens will contain a content wrapper, and larger screens will only show one line as the content fits.
Here is the XAML:
<ListView.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width="45" /> <ColumnDefinition Width="45" /> <ColumnDefinition Width="45" /> <ColumnDefinition Width="45" /> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Content}" Padding="20,6,6,6" /> <TextBlock Text="X" Grid.Column="1" HorizontalAlignment="Center" /> <TextBlock Text="X" Grid.Column="2" HorizontalAlignment="Center" /> <TextBlock Text="X" Grid.Column="3" HorizontalAlignment="Center" /> <TextBlock Text="X" Grid.Column="4" HorizontalAlignment="Center" /> </Grid> </DataTemplate> </ListView.ItemTemplate>
listview wpf grid textwrapping
Rubyhouse
source share