In my application I have a ListView
where I defined its ItemTemplate
as follows:
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch" Background="Aqua">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="ParameterIconSize" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ParameterDescriptionSize" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ParameterValueSize" />
</Grid.ColumnDefinitions>
<Image
Grid.Column="0"
MaxHeight="50"
Margin="5"
Grid.IsSharedSizeScope="True"
Source="{Binding Path=Icon}" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Grid.IsSharedSizeScope="True"
Text="{Binding Path=Parameter.NameKey}" />
<TextBox
Grid.Column="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
Grid.IsSharedSizeScope="True"
Text="{Binding Path=Parameter.Value}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Such code produces this output:
As you can see, nearly every column has a different width, whilst I wanted to make them even. I thought that going with SharedSizeGroup
was the right way, but clearly there is something I am missing...
(PS: I had to set the maxHeight in the Image element because if not this would show:
)
I would like to have all three columns the same size, determined by these criteria:
- column 0: largest image
- column 1: largest textbox text
- column 2: fill the remainig space (as this is also a user input field, and I cannot know a priori if that input will be something like 0 or 1438233482379472 )
EDIT 2: I forgot to specify that I want the textboxes in column 2 to be the same size, filling the available space.