I know how column definition in XAML works, but there is something I want to do, and I donβt know how to do it.
I need 4 columns:
<Grid.ColumnDefinitions> <ColumnDefinition Width="110" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="80" /> <ColumnDefinition Width="80" /> </Grid.ColumnDefinitions>
- Column
- has a fixed width Column
- should take all available space (yes, this is between the columns, and this is definitely the problem). Column
- has a fixed width Column
- has a fixed width
The second column contains text, and the problem is that when this text is too short, the second column does not take up all the free space. it gets smaller automatically, and this is for each row. I can get it to work with this code in a text block:
MinWidth="2000"
But this is not very good, as this number may be too low when the screen is large.
Here is the whole list containing 4 columns:
<ListView Grid.Row="1" Grid.ColumnSpan="4" ItemsSource="{Binding blabla}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="110" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="80" /> <ColumnDefinition Width="80" /> </Grid.ColumnDefinitions> <Image Height="110" Width="110" Grid.Column="0" Source="{Binding blabla}" HorizontalAlignment="Stretch" /> <TextBlock Text="{Binding blabla}" TextWrapping="Wrap" Margin="5,0,0,0" Grid.Column="1" FontSize="16" HorizontalAlignment="Stretch" TextAlignment="Left" FlowDirection="LeftToRight" MinWidth="2000" VerticalAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Disabled" FontStretch="UltraCondensed"/> <TextBlock Grid.Column="2" TextWrapping="Wrap" Foreground="Black" Margin="5,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Center"/> <Image Source="{Binding blabla, Converter={StaticResource ImgConverter}}" Grid.Column="3" Width="76" Height="76" HorizontalAlignment="Center" Stretch="None" VerticalAlignment="Center" Margin="0"/> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView>
source share