Main Widow Appears on top of the Navigated Window In WPF Navigation Service

Posted by Vuyiswamb under WPF on 2/6/2013 | Points: 10 | Views : 1370 | Status : [Member] [MVP] [Administrator] | Replies : 1
Good Day All

i am building Kinect Application, obviously using WPF.. Now i have a problem with Navigation. I have a Window and others are Pages that will use a Frame in a Window. So the Window has Button to Main to the "Menu" so the Page that contains Menu's is called "MainMenu.xaml"

 
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
_mainFrame.Source = new Uri("/MainMenu.xaml", UriKind.Relative);
}



now when i navigate to the Menu Page , it shows my Menu page ,but the Window Button is not hidden.

So Before i used to have the code to navigate to the "MainMenu.xaml" in the loaded event of the Window so that it directly moved to the Menu, but my Problem is that still behind even if its behind my Kinect Gesture can click or touch the menu's in the "MainMenu.xaml" it looks like they are not out of scope.

When i move from **MainMenu.xaml** to the selected menu page i do it this way


(Application.Current.MainWindow.FindName("_mainFrame") as Frame).Source = new Uri("/Alphabets101/Menu.xaml", UriKind.Relative);


but still you will see that it tries to Access a "MainMenu" even if they are not visible on the screen

Thanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: Raj.Net on: 4/10/2013 [Member] Starter | Points: 25

Up
0
Down

hi!!!
i had used RoutedEventArgs please follow the steps.

Step1:App.xaml
<Application x:Class="CRC.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Start" >
</Application>

Step2:App.cs
public partial class App : Application
{
private void Application_Start(Object sender, System.Windows.StartupEventArgs e)
{

MainWindow mainWindow = new MainWindow();
mainWindow.ShowDialog();
}
}
}
Step3:MainWindow.Xaml
<Window x:Class="CRC.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CRC"
Title="CRC Application" Width="1280" Height="960"


MinHeight="800" MinWidth="600" HorizontalAlignment="center" mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="960"
d:DesignWidth="1280" WindowState="Maximized" WindowStyle="None" Topmost="False" MouseDown="MainWindow_MouseDown" AllowsTransparency="False" Visibility="Collapsed">

<Grid x:Name="grdMain" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Viewbox Stretch="Fill">
<Frame x:Name="_mainFrame" NavigationUIVisibility="Hidden" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="0" ClipToBounds="False"/>
</Viewbox>
</Grid>

</Window>

Step4:Wpf Page
namespace Application
{
/// <summary>
/// Interaction logic for wpfPage.xaml
/// </summary>
public partial class wpf : Page
{

public static readonly RoutedEvent TimeOutEvent = EventManager.RegisterRoutedEvent("TimeOut", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(WpfPage));
//******************************************
public AddressPage()
{
InitializeComponent();

}
public event RoutedEventHandler TimeOut
{
add { AddHandler(TimeOutEvent, value); }
remove { RemoveHandler(TimeOutEvent, value); }
}

void RaiseTimeOutEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(WpfPage.TimeOutEvent);
RaiseEvent(newEventArgs);
}
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
RaiseTimeOutEvent();
}
}
Step5:Mainwindow.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializePage();
}
private void InitializePage()
{
WpfPage wpfpage=new WpfPage();
this.AddHandler(WpfPage.TimeOutEvent, new RoutedEventHandler(HandleWpfPageTimeOut));
}
private void HandlePageTimeOut(object sender, RoutedEventArgs args)
{
_mainframe.navigate(wpfpage);
}
}

BY
Rajesh
MY Mail Id:rajesh4132@gmail.com
India

If it helps/directs you towards the solution,Mark This Response as Answer link
--
Rajesh

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response