I have an WPF usercontrol which contains following grid.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
Width="24"
Height="24"
Margin="8"
Visibility="{Binding Path=IsVisible, Converter={StaticResource InvertBoolToVisibility}}"
Source="{Binding Path=MyIcon}"/>
<Label Grid.Column="1"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="Auto"
Margin="5"
Foreground="{Binding Path=ForegroundColor}">
<TextBlock Text="{Binding Path=Text}" TextWrapping="Wrap"/>
</Label>
<Button Grid.Column="2"
Width="80"
Height="28"
VerticalAlignment="Center"
HorizontalAlignment="Left"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Margin="5,5,30,5"
Padding="5"
Content="Remove All"
Foreground="Red"
Visibility="{Binding Path=IsVisible, Converter={StaticResource BoolToVisibility}}"
Click="RemoveAll_Click"/>
<Image Grid.Column="3"
Width="36"
Height="36"
Margin="8,2"
Visibility="{Binding Path=IsVisible, Converter={StaticResource InvertBoolToVisibility}}"
Source="{Binding Path=MyLogo}" />
</Grid>
The problem with above grid is that button is not placed just after the Label content, instead when label content is short there is a huge space between the label content and the button.
I would like to put the button just after the label content, I don't want any space between label and button. How can I do this?
See below screenshot to see what's happening (each time I resize the window to right, there is more space between label and button):
I need the button to always keep on the right of the label (this is already working),