[英]C# Multi Page WPF App, Height & Width of pages not the same
I am trying to create my first C# app and ran into a problem. 我正在尝试创建我的第一个C#应用程序并遇到问题。
MainWindow.xaml code below MainWindow.xaml代码如下
<NavigationWindow x:Class="WPF_Navigation.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF_Navigation"
mc:Ignorable="d"
Title="MainWindow" Height="350px" Width="525px" Source="incl/pages/Login.xaml">
Login.xaml code below 下面的Login.xaml代码
<Page x:Class="WPF_Navigation.incl.pages.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPF_Navigation.incl.pages"
mc:Ignorable="d"
Height="350px" Width="525px"
Title="Login">
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="440,320,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
As you can see the height and width is exactly the same on both and the button is in the bottom right corner well within the 350px X 525px window. 如您所见,两者的高度和宽度完全相同,并且按钮位于350px X 525px窗口的右下角。 So why is it that when I run the app the button is out off screen?
那么为什么当我运行该应用程序时,该按钮不在屏幕上? (had to resize window as seen in the image below)
(必须调整窗口大小,如下图所示)
The windows height includes all of its ui: your page + title + borders + ???. Windows高度包括其所有ui:您的页面+标题+边框+ ???。 See this example
看这个例子
<Window
x:Name="TheWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="200">
<Grid x:Name="TheGrid">
<TextBlock Text="{Binding Path=ActualHeight, ElementName=TheGrid}" />
</Grid>
</Window>
yields this: 产生这个:
So there is a difference of 39 pixels for the window ui (will vary depending on your os). 因此,窗口ui的差异为39像素(具体取决于您的操作系统)。
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.