我想像这张照片一样控制位置
我需要将下一个和上一个按钮设为pic 1
,但我得到以下内容,但无法解决此问题。
请指导,XAML代码:
<StackPanel Grid.Row="4">
<Grid x:Name="GridNavigation">
<Button x:Name="Gridprevbutton" Content="Previous" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="121,0,0,0"></Button>
<Button x:Name="Gridnextbutton" Content="Next" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="231 , 0, 0, 0"></Button>
<Button x:Name="Gridendexambuton" Content="End Exam" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,0,5,0"></Button>
</Grid>
<TextBlock HorizontalAlignment="Right" Margin="0,5,10,0" TextDecorations="Underline">Contact Support</TextBlock>
</StackPanel>
(编辑)我最后在@davisoa建议之后这样做了。并使它工作。
背后的代码
private void SetNavigation()
{
var img = Common.AddImageToContainer("images/lowerleftblock.png", GridNavigation, Common.ToDictionaryTLST("top", "left", "none"));
img.Margin = new Thickness(0,16,0,0);
Panel.SetZIndex(img, -1);
}
答案 0 :(得分:1)
在我看来,上面没有显示的Grid
(StackPanel
中的第一个Grid.Row="4"
)限制了“下一个”和“上一个”按钮的高度。
此示例XAML显示问题块低于按钮。
Image
更改为StackPanel
Label
,因为我没有您的图片VerticalAlignment
更改为Bottom
,以确保其浮动在Grid
Grid
一个固定的Height
以确保垂直布局正确。你可能不想这样做<StackPanel Grid.Row="4">
<Grid x:Name="GridNavigation" Margin="0,0,0,0" Height="75">
<StackPanel x:Name="Lowerleftblock" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0,0,0,0" Background="Green">
<Label>Question: 1 of 27</Label>
</StackPanel>
<Button x:Name="Gridprevbutton" Content="Previous" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="121,0,0,0"></Button>
<Button x:Name="Gridnextbutton" Content="Next" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="231 , 0, 0, 0"></Button>
<Button x:Name="Gridendexambuton" Content="End Exam" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,0,5,0"></Button>
</Grid>
<TextBlock HorizontalAlignment="Right" Margin="0,5,10,0" TextDecorations="Underline">Contact Support</TextBlock>
</StackPanel>
答案 1 :(得分:1)
为您的图像提供最高限度,以便将其降低。 E.g。
<Image x:Name="Lowerleftblock" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,20,0,0"></Image>