[英]XAML alignment in Windows 8 Store App
Not being at all familiar with XAML, I'm trying to get a very simple layout designed where the main page consists of two parts: 我一点都不熟悉XAML,我试图设计一个非常简单的布局,主页面由两部分组成:
I can get the image to behave ok by using a ViewBox
but I can't seem to get the right side of the screen to fill the remaining gap. 我可以通过使用
ViewBox
使图像表现良好,但我似乎无法获得屏幕的右侧来填补剩余的差距。 See screenshot: 看截图:
What I want is for the area that contains the text to stretch to the right with the text centred within it. 我想要的是包含文本的区域向右伸展,文本居中于其中。
The relevant XAML code is: 相关的XAML代码是:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Horizontal">
<Viewbox HorizontalAlignment="Right">
<Image Source="Assets/ABCImage.png"></Image>
</Viewbox>
<StackPanel Orientation="Vertical">
<TextBlock Text="ABC Viewer"
TextAlignment="Center"
FontSize="48"></TextBlock>
<TextBlock Text="Test application"
TextAlignment="Center"
FontSize="24"></TextBlock>
</StackPanel>
</StackPanel>
</Grid>
This is taking me far too long to figure out. 这让我花了很长时间才弄明白。 Can someone please put me out of my misery?
有人可以把我从痛苦中解救出来吗?
Try this : 尝试这个 :
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Viewbox Grid.Column="0"
HorizontalAlignment="Right">
<Image Source="Assets/ABCImage.png"></Image>
</Viewbox>
<StackPanel Grid.Column="1">
<TextBlock Text="SEM Viewer"
TextAlignment="Center"
FontSize="48" />
<TextBlock Text="Test application"
TextAlignment="Center"
FontSize="24" />
</StackPanel>
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.