我正在用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;
}
我可以轻松设置画布,因为它覆盖整个屏幕。但我不确定如何接近appbar。我很惊讶没有一个属性会自动将栏标记到屏幕底部。
以下是应用栏的XAML:
<AppBar x:Name="mainBar" Canvas.Top="700" Width="1366" VerticalAlignment="Bottom">
<Button Style="{StaticResource NewWindowAppBarButtonStyle}" Click="Button_Click_1" />
</AppBar>
很抱歉,如果有人问这个问题。我一直在寻找各种年龄,找不到任何可以帮助我的东西。
由于
答案 0 :(得分:3)
为什么不试试这个。这将打开页面底部的应用栏,无论屏幕分辨率如何。
<Page.BottomAppBar>
<AppBar x:Name="mainBar" Padding="10,0,10,0" AutomationProperties.Name="Bottom App Bar" IsOpen="True">
<Button Style="{StaticResource NewWindowAppBarButtonStyle}" Click="Button_Click_1" />
</AppBar>
</Page.BottomAppBar>
答案 1 :(得分:0)
如果要求画布,则可以使用此
设置宽度和高度protected override void OnNavigatedTo(NavigationEventArgs e)
{
var bounds = Window.Current.Bounds;
can.Height = bounds.Height;
can.Width = bounds.Width;
}
还尝试实施尺寸更改事件
Window.Current.SizeChanged += OnWindowSizeChanged;
并在那里应用