Viren Martins

Viren Martins

  • NA
  • 18
  • 1.5k

Navigate pages in a frame when clicking on menu items

Sep 1 2017 2:53 AM
Hi Guys,
 
I am new to WPF and having trouble with the basics of menuitems and frames.
 
I have a main window  where i have created menu items and a frame. what i am trying to do is on clicking any menu item i want the corresponding page to load up in the frame.  I have called the frame "Main"
 
 
one of my menu items is task updates and i have created a click event "Taskupdates". is this correct?
  1. <MenuItem Header="TASK UPDATES" Click="taskupdates"/>  
The mainwindow xaml.cs has the code below. 
  1.   
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    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 LES
    {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();
    Application.Current.MainWindow.WindowState = WindowState.Maximized;
    }
    private void taskupdates(object sender, RoutedEventArgs e)
    {
    Main.Content = new CFM_Task_Updates();
    }
    }
    }
 What i am trying to do is on clicking task updates , i want the CFM _Task_updates.xaml page to load in the frame called "main" in my main window.
 
how do i do this? 
 
Any help would be greatly appreciated .
 
Cheers
 V 

Answers (2)