Search code examples
winrt-xamlstackpanel

How to align image content on stackpanel in metro app


I've got a Stackpanel which is set to horizontal orientation and Horizontal alighment is set to Stretch. Inside it I've got two elements: 1. TextBlocks 2. Image. I want the 2nd one to display on extreme right.

<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
    <TextBlock>Hello World</TextBlock>
    <Image Height="100" Width="100" />
</StackPanel>

How do I accomplish it?


Solution

  • You almost had it.

    <Grid>
        <TextBlock>Hello World</TextBlock>
        <Image Height="100" Width="100" HorizontalAlignment="Right" />
    </Grid>
    

    Just don't use a StackPanel.

    // Best of luck!