✅ Navigating my window only display the next page's name instead of its contents

I hope you're all well. I got stuck on a WPF XAML problem where my pages wouldn't navigate and after a while of research, I still can't seem to figure it out. Basically, I have my Main Window page which has a button event that changes the page's content using the frame to the content of the new page ("OrdersPage.xaml") I've written my MainWindow XAML like so:
<Controls:MetroWindow x:Class="DatabaseTest.MainWindow"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowTitleBrush="Gray" GlowBrush="Black"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid Background="#312F2F">
<Frame x:Name="mainFrame"/>
...
<Controls:MetroWindow x:Class="DatabaseTest.MainWindow"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowTitleBrush="Gray" GlowBrush="Black"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid Background="#312F2F">
<Frame x:Name="mainFrame"/>
...
My OrdersPage looks like this:
<Controls:MetroWindow x:Class="DatabaseTest.OrdersPage"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DatabaseTest"
mc:Ignorable="d"
Title="OrdersPage" Height="450" Width="800">
<Grid>
<TextBlock Text="Hello"></TextBlock>
</Grid>
...
<Controls:MetroWindow x:Class="DatabaseTest.OrdersPage"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DatabaseTest"
mc:Ignorable="d"
Title="OrdersPage" Height="450" Width="800">
<Grid>
<TextBlock Text="Hello"></TextBlock>
</Grid>
...
And in the C# behind this class is a method that handles a button press which looks like this:
public partial class MainWindow
{
public static NavigationService NavigationService => ((MainWindow)Application.Current.MainWindow).mainFrame.NavigationService;

...

private void SendCustomerBtn_Click(object sender, RoutedEventArgs e)
{
if(parseCustomer is not null)
{
MainWindow.NavigationService.Navigate("OrdersPage.xaml");
}
}
public partial class MainWindow
{
public static NavigationService NavigationService => ((MainWindow)Application.Current.MainWindow).mainFrame.NavigationService;

...

private void SendCustomerBtn_Click(object sender, RoutedEventArgs e)
{
if(parseCustomer is not null)
{
MainWindow.NavigationService.Navigate("OrdersPage.xaml");
}
}
From what I wrote and reading off of other articles I believe that this is written correctly, however when I run my program and click on the button it displays in the top left-corner, "OrdersPage.xaml" as a small black text. (Image here): I am really confused on why this is happening and would appreciate any help.
4 Replies
Pink Elsa💖
Pink Elsa💖OP2y ago
Anyone know how to resolve this please ?
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Pink Elsa💖
Pink Elsa💖OP2y ago
Still waiting for help while attempting other solutions
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server