如何计算页面分辨率
本文关键字:分辨率 计算 何计算 | 更新日期: 2023-09-27 18:14:35
我有一个表格格式的问题。主页的高度和宽度已更改为1024 X 760。每一行和列都被正确划分,也有额外的空间,但当我调试程序时,页面看起来像半页被"某些东西"覆盖。
d:DesignWidth="640" d:DesignHeight="700"
Title="ConsultationPage Page" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot">
<sdk:Label Height="28" HorizontalAlignment="Left" Name="lblCTitle" VerticalAlignment="Top" Width="50" Content="Consultation Hour" Margin="12,0,0,0" />
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="508,14,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="427,14,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
<Grid x:Name="TableLayoutRoot" Margin="-1,70,0,-70">
<Grid.RowDefinitions>
<RowDefinition Height="40">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="20">
</RowDefinition>
<RowDefinition Height="*">
</RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="*">
</ColumnDefinition>
</Grid.ColumnDefinitions>
<sdk:Label Height="38" HorizontalAlignment="Left" Name="lblMonday" VerticalAlignment="Top" Width="200" Grid.Column="1" Grid.Row="0" FontSize="24" Foreground="#B4000000" Content="Monday" FontFamily="Comic Sans MS" Margin="50,0,0,0"/>
<sdk:Label Height="38" HorizontalAlignment="Left" Name="lblTuesday" VerticalAlignment="Top" Width="200" Grid.Column="2" Grid.Row="0" FontSize="24" Foreground="#B4000000" Content="Tuesday" FontFamily="Comic Sans MS" Margin="50,0,0,0"/>
<sdk:Label Height="38" HorizontalAlignment="Left" Name="lblWednesday" VerticalAlignment="Top" Width="200" Grid.Column="3" Grid.Row="0" FontSize="24" Foreground="#B4000000" Content="Wednesday" FontFamily="Comic Sans MS" Margin="50,0,0,0"/>
<sdk:Label Height="38" HorizontalAlignment="Left" Name="lblThursday" VerticalAlignment="Top" Width="200" Grid.Column="4" Grid.Row="0" FontSize="24" Foreground="#B4000000" Content="Thursday" FontFamily="Comic Sans MS" Margin="50,0,0,0"/>
<sdk:Label Height="38" HorizontalAlignment="Left" Name="lblFriday" VerticalAlignment="Top" Width="200" Grid.Column="5" Grid.Row="0" FontSize="24" Foreground="#B4000000" Content="Friday" FontFamily="Comic Sans MS" Margin="50,0,0,0"/>
</Grid>
我将抛出一些XAML给你,看看它是否能帮助你,因为我仍然不太确定你的问题是什么。尝试使用这个布局XAML:
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="23" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75" />
<ColumnDefinition Width="75" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Name="lblCTitle" VerticalAlignment="Top" Text="Consultation Hour" />
<Button Grid.Row="1" Grid.Column="0" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Grid.Row="1" Grid.Column="1" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Grid x:Name="TableLayoutRoot" Grid.Row="2" Grid.ColumnSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="200">
</ColumnDefinition>
<ColumnDefinition Width="*">
</ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Center" Name="lblMonday" VerticalAlignment="Top" Grid.Column="1" Grid.Row="0" FontSize="24" Foreground="#B4000000" Text="Monday" FontFamily="Comic Sans MS" />
<TextBlock HorizontalAlignment="Center" Name="lblTuesday" VerticalAlignment="Top" Grid.Column="2" Grid.Row="0" FontSize="24" Foreground="#B4000000" Text="Tuesday" FontFamily="Comic Sans MS" />
<TextBlock HorizontalAlignment="Center" Name="lblWednesday" VerticalAlignment="Top" Grid.Column="3" Grid.Row="0" FontSize="24" Foreground="#B4000000" Text="Wednesday" FontFamily="Comic Sans MS" />
<TextBlock HorizontalAlignment="Center" Name="lblThursday" VerticalAlignment="Top" Grid.Column="4" Grid.Row="0" FontSize="24" Foreground="#B4000000" Text="Thursday" FontFamily="Comic Sans MS" />
<TextBlock HorizontalAlignment="Center" Name="lblFriday" VerticalAlignment="Top" Grid.Column="5" Grid.Row="0" FontSize="24" Foreground="#B4000000" Text="Friday" FontFamily="Comic Sans MS" />
</Grid>
</Grid>
我只想在这里指出几件事。首先,它看起来像你试图使用Margin
在你的控制上做定位。这不是用Silverlight或WPF在基于xaml的布局中做事的方式。使用<Grid>
,或者学习使用<StackPanel>
甚至<DockingPanel>
—您会发现它们中的每一个都适合某些布局目的,并且它们的组合通常最适合获得您所需的布局。另一件你可能想做的事情是我在这里没有做的,那就是使用StaticResource
或Style
来设置你的字体大小、颜色和字体系列——这样做可以让你在一个地方改变这些设置,而不是很多(在这个例子中是五个)。