Align Grid column to right Align Grid column to right wpf wpf

Align Grid column to right


As you mentioned its an ItemTemplate of ListBox, what you can do is set HorizontalContentAlignment to Stretch.

    <ListBox>        <ListBox.ItemContainerStyle>            <Style TargetType="ListBoxItem">                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>            </Style>        </ListBox.ItemContainerStyle>    </ListBox>


Try with this :

<Grid Background="Transparent" Margin="0,3">        <Grid.ColumnDefinitions>            <ColumnDefinition Width="Auto"/>            <ColumnDefinition Width="*"/>        </Grid.ColumnDefinitions>    <StackPanel Orientation="Horizontal">        <Image x:Name="Selected" Width="48" Height="48"  VerticalAlignment="Center" Stretch="Uniform" HorizontalAlignment="Center"/>        <TextBlock x:Name="Name" TextAlignment="Left" VerticalAlignment="Center" Margin="20,0" />    </StackPanel>    <Image Grid.Column="1" x:Name="Selected" Width="48" Height="48"  VerticalAlignment="Center" Stretch="Uniform" HorizontalAlignment="Right"/> </Grid>


Try HorizontalAlignment="Stretch" in Grid.