如何在metro应用程序中的stackpanel上对齐图像内容(How to align image content on stackpanel in metro app)

我有一个设置为水平方向的Stackpanel,而Horizo​​ntal alighment设置为Stretch。 在里面我有两个元素:1。TextBlocks 2.图像。 我希望第二个显示在极右侧。

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

我该如何完成它?

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?

最满意答案

你几乎拥有它。

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

只是不要使用StackPanel 。

//祝你好运!

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!

如何在metro应用程序中的stackpanel上对齐图像内容(How to align image content on stackpanel in metro app)

我有一个设置为水平方向的Stackpanel,而Horizo​​ntal alighment设置为Stretch。 在里面我有两个元素:1。TextBlocks 2.图像。 我希望第二个显示在极右侧。

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

我该如何完成它?

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?

最满意答案

你几乎拥有它。

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

只是不要使用StackPanel 。

//祝你好运!

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!