【发布时间】:2013-09-27 23:15:10
【问题描述】:
我正在用 c# 构建一个 Windows 8 应用程序,但我无法让应用程序栏停留在屏幕底部。
我正在 2560x1440 的 PC 显示器和 1366x768 的 Windows 表面上测试该程序。它非常适合(默认情况下)Windows Surface 设备,但会显示在 PC 显示器的屏幕中间。
这是我所拥有的:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
can.Height = user.screenHeight; //Can is a canvas, which is being drawn on to.
can.Width = user.screenWidth; //user class contains information about the current user of the program
var resScale = Windows.Graphics.Display.DisplayProperties.ResolutionScale;
}
我可以轻松设置画布,因为它覆盖了整个屏幕。但我不确定如何接近应用栏。我很惊讶没有一个属性会自动将栏标记到屏幕底部。
这是应用栏的 XAML:
<AppBar x:Name="mainBar" Canvas.Top="700" Width="1366" VerticalAlignment="Bottom">
<Button Style="{StaticResource NewWindowAppBarButtonStyle}" Click="Button_Click_1" />
</AppBar>
抱歉,如果有人问过这个问题。只是我一直在四处寻找,找不到任何可以帮助我的东西。
谢谢
【问题讨论】:
-
Canvas不是用于布局 UI 元素的合适容器。使用Grid或DockPanel之类的 -
将画布放入网格中?我正在使用画布,因为我的程序需要绘制到窗口。
-
您将
AppBar放在画布内,这是错误的。使用Grid或其他一些用于布局的容器。
标签: c# xaml windows-8 microsoft-metro