我遇到表格式问题。 MainPage的高度和宽度已经变为1024 X 760.每个ROW和COLLUMN都被正确划分并且还有额外的空间,但是当我调试程序时,页面似乎被“Something”所覆盖的半页看不见。
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>
答案 0 :(得分:0)
我要扔掉一些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
作为你的字体大小,颜色和家庭 - 这样做可以让你改变这些设置在一个地方而不是很多(在这种情况下为五个)。