WPF: Horizontal Alignment

Posted by emptyset on Stack Overflow See other posts from Stack Overflow or by emptyset
Published on 2010-03-16T16:29:40Z Indexed on 2010/03/16 16:31 UTC
Read the original article Hit count: 291

Filed under:

Probably I'm just missing something obvious, but I can't get the image in my DataTemplate to align to the right in the Grid, so that when the window is stretched, the image is "pulled" to the right as well:

<Window.Resources>
    <DataTemplate x:Key="PersonTemplate" DataType="Minimal.Client.Person">
        <Border BorderBrush="Purple" BorderThickness="2" CornerRadius="2" Padding="5" Margin="5">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" MinWidth="200"/>
                    <ColumnDefinition Width="Auto" MaxWidth="200"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column ="0" Orientation="Horizontal" >
                    <TextBlock FontFamily="Verdana" FontSize="16" FontWeight="Bold" Text="{Binding LastName}" />
                    <TextBlock FontFamily="Verdana" FontSize="16" Text=", " />
                    <TextBlock FontFamily="Verdana" FontSize="16" Text="{Binding FirstName}" />
                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Right">
                    <Border BorderBrush="Black" BorderThickness="1">
                        <Image Source="{Binding Picture}" Width="180" Height="150" />
                    </Border>
                </StackPanel>
            </Grid>
        </Border>
    </DataTemplate>
</Window.Resources>

Any suggestions?

© Stack Overflow or respective owner

Related posts about wpf