窗口和页面重叠

问题描述 投票:-1回答:1

我正在尝试构建一个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>
c# wpf
1个回答
0
投票

您必须添加父容器面板,如网格,Dock等。

<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>
© www.soinside.com 2019 - 2024. All rights reserved.