我正在尝试构建一个WPF应用程序,我应该在MyPage中显示该集合。我在MainWindow中创建了一个按钮,它触发LoadCollection()并在MyPage中显示它,但它与MainWindow中的对象重叠。
有人能指出我正确的方向吗?我错过了什么? 页面不应该像一张“干净的纸”吗?
这是我的MainWindow.xaml代码:
<TextBlock HorizontalAlignment="Center">Welcome to Stefan's Test</TextBlock>
<TextBlock HorizontalAlignment="Center" TextAlignment="Center" Margin="114,54,93,0" Width="310">Start your test by choosing the difficulty</TextBlock>
<StackPanel Orientation="Horizontal" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="Beginner" MinWidth ="100" Click="BtnClickP1"/>
<Button Content="Intermediate" MinWidth="100" Margin="10, 0, 0, 0" Click="BtnClickP2"/>
<Button Content="Expert" MinWidth="100" Margin="10, 0, 0, 0" Click="BtnClickP3"/>
</StackPanel>
<Frame x:Name="Main" Margin="0, 0, 0, 0"></Frame>
答案 0 :(得分:0)
你必须添加一个像网格,Dock等一样的paren容器面板。
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">Welcome to Stefan's Test</TextBlock>
<TextBlock Grid.Row="1" HorizontalAlignment="Center" TextAlignment="Center" Margin="114,54,93,0" Width="310">Start your test by choosing the difficulty</TextBlock>
<StackPanel Grid.Row="2" Orientation="Horizontal" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="Beginner" MinWidth ="100"/>
<Button Content="Intermediate" MinWidth="100" Margin="10, 0, 0, 0"/>
<Button Content="Expert" MinWidth="100" Margin="10, 0, 0, 0"/>
</StackPanel>
<Frame Grid.Row="3" x:Name="Main" Margin="0, 0, 0, 0"></Frame>
</Grid>