WPF导航到新页面仅显示页面的一半

时间:2019-11-30 05:48:18

标签: c# wpf navigation

当前,我正在尝试在加载窗口时在同一窗口内显示另一个页面。程序可以很好地导航到新页面,但页面上的数据已被切断(排序类似于半张图片)。

我的主窗口的代码很简单:

<DockPanel>
   <Frame x:Name="_mainFrame" />
</DockPanel>

public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            _mainFrame.Content = new MainPage();
        }

第二页的代码仅是xaml:

<Grid Background="AliceBlue">
        <TextBlock Text="Welcome To The Store!" TextWrapping="Wrap" TextAlignment="Center" Foreground="DarkBlue" FontSize="40" FontFamily="Algerian" Margin="0,0,0,340"/>
        <Button x:Name="ExistingCustomer" Content="Existing Customer" Height="25" Width="105" Margin="348,160,347,265"/>
        <Button x:Name="NewCustomer" Content="New Customer" Margin="348,210,347,215" Height="25" Width="105"/>
        <Button x:Name="Guest" Content="Guest" Margin="348,265,347,160" Height="25" Width="105"/>
    </Grid>

页面在文本块中途停止,并且不显示任何按钮。

我尝试将MainWindow_Loaded代码更改为_MainFrame.Navigate(new MainPage());this.content = new MainPage();,但问题仍然存在。

编辑

添加了屏幕截图:

The Page should Display this

Instead, it Displays this

0 个答案:

没有答案
相关问题