C# 无论屏幕分辨率如何,如何使应用程序栏保持在底部?
我正在用c#构建一个Windows 8应用程序,但我无法让应用程序栏停留在屏幕底部 我正在2560x1440 PC显示器和1366x768 Windows界面上测试该程序。它完全适合(默认)Windows表面设备,但显示在屏幕上的PC监视器的中间。 以下是我所拥有的:C# 无论屏幕分辨率如何,如何使应用程序栏保持在底部?,c#,xaml,windows-8,microsoft-metro,C#,Xaml,Windows 8,Microsoft Metro,我正在用c#构建一个Windows 8应用程序,但我无法让应用程序栏停留在屏幕底部 我正在2560x1440 PC显示器和1366x768 Windows界面上测试该程序。它完全适合(默认)Windows表面设备,但显示在屏幕上的PC监视器的中间。 以下是我所拥有的: protected override void OnNavigatedTo(NavigationEventArgs e) { can.Height = user.screenHeight; //Can is a canv
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>
如果有人问这个问题,我很抱歉。只是我已经到处找了很久,找不到任何对我有帮助的东西
谢谢你为什么不试试这个呢。这将打开页面底部的应用程序栏,无论屏幕分辨率如何
<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>
如果需要画布,则可以使用此选项设置宽度和高度
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var bounds = Window.Current.Bounds;
can.Height = bounds.Height;
can.Width = bounds.Width;
}
还可以尝试实现大小更改事件
Window.Current.SizeChanged += OnWindowSizeChanged;
在那里应用同样的方法,A
Canvas
不是一个合适的容器来布局UI元素。使用网格
或DockPanel
或其他东西将画布放入网格?我使用画布是因为我的程序需要在窗口中绘图。你把AppBar
放在画布中,这是错误的。使用网格
或其他用于布局的容器。