Foreword: I'm posting this here as I didn't get any replies to my post here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5d7d4554-7d4b-45af-b02c-22ed0c7695a2/navigation-in-c-xaml-not-working?forum=vsta
I know Stackoverflow is a much more reliable source, so I decided to repost it here.
I'm trying to make make my first app in VS, and I want it to just be an informational App about cubing (Solving Rubik's style cubes very fast.) I am just learning the basics of C# and XAML at the moment, but am unable to get navigation between pages. All tutorials I have seen say use the line of code:
this.Frame.Navigate(typeof(PLL), null);
But it gives me this error:
'Mainwindow' does not contain a definition for 'Frame' and no extension method 'Frame' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference? I also want to point out that they say to use the 'Blank App' Template, but I can't seem to find that - is it not in VS community? Instead, I had to use the WPF app template.
What am I doing wrong? How can I get these links between pages working?
Below is the whole of my C# and XAML code.
Thanks!
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CubingGuide
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void GoToPLL(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(PLL), null);
}
}
}
XAML:
<Window x:Class="CubingGuide.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CubingGuide"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="GoToPLLButt" Margin="10,10,360,251" Content="PLL" Click="GoToPLL"/>
</Grid>
</Window>