WPF c# window navigation


i got 2 window , i want to navigate from one another but i when i debug it , it shows that nav is null , why is that so? Does it suppose to be null? because i used the same way to navigate in the past and it work and i try it now , it doesn't work. But if i put nav == null , it says

nav.Navigate(new Uri("HomeMenu.xaml", UriKind.RelativeOrAbsolute));

is null

here is what i have :

            NavigationService nav = NavigationService.GetNavigationService(this);
        if (nav != null)
            nav.Navigate(new Uri("HomeMenu.xaml", UriKind.RelativeOrAbsolute));

is this how i can navigate from a Window to user control page?

1 Answer: 

GetNavigationService returns null when the dependencyObject:

  • Is a NavigationWindow.

  • Is a Frame that:

    1) Is hosted by another navigator.

    2) Has its JournalOwnership property set to UsesParentJournal.

  • Is not part of content that is hosted by a navigator.



More Articles

java - I want to change the color of Toolbar of the application on scrolling

I have a toolbar that change color on scrolling basicly color is transparent and when scrolling it change color I want to set only one color instead of transparent and let one color be shownI have tried to change color on toolbar xml and display scroling in activitythis my toolbar.xml<?xml versio

visual c++ - OnInitMenuPopup does not init correctly when called from a toolbar button that was a POPUP menu in the App main menu bar

To make a long history short, imagine my main menu is a CMFCMenuBar which menu is defined by:IDR_MAINFRAME MENUBEGIN POPUP "&File" BEGIN MENUITEM "New", ID_FILE_NEW MENUITEM "Open", ID_FILE_OPEN MENUITEM "Save", ID_FILE_SAVE

ios - How to create toolbar in separate xib file and separate class and use it in multiple view controllers?

How to create a toolbar in a separated xib file and separate class and use it in multiple view controllers?

android - Single Activity and Multiple Fragment with different toolbar layouts

I have an app with Single Activity multiple Fragments architecture in my app. The problem is, there is one listing fragment with normal Toolbar, from here user can click and go to Details screen. Now in Details screen, I want the Activity to become Fullscreen with CoordinatorLayout and Collapsing To

c++ - MFC: How to save the position of toolbars in the legacy MFC ver 6?

I have a striking question: How to save the position of toolbars in the legacy MFC ver 6?I can't use CWinApp::SaveBarState because not all toolbars exist at the moment this function would be called (causing it to assert). Instead, I instantiate the toolbars depending on what kind of document is load

android - Horizontal and Vertical linear layout inside a scroll view

I am trying to get a combination of Views established. They must constantly have a Button and Edittext box at the top horizontally next to each other and below that a vertical list of Textviews. The vertical list should be enclosed in a ScrollView to allow the user to scroll down through the TextVie

WPF Frame Source Refreshing the Loaded Page

I've come across a strange scenario where a frame refuses to refresh its content.I can kinda understand what's happening but the solution is not coming to me.I have a page that has a frame (Frame1) and several buttons. When I click on a button a page is loaded into the frame. This works perfectly in

Android: pin TabLayout to top of Scrollview

I was looking at the twitter app on my phone.You can see that when a user scrolls up, the tabLayout actually just pins itself onto the bottom of the toolbar nicely and does not move at all.I thought maybe they did it by just putting all of the top part of the app (the profile picture, the profile wa

material design - android lollipop toolbar: how to hide/show the toolbar while scrolling?

I'm using the new toolbar widget introduced in the appcompat / support-v7. I would like to hide/show the toolbar depending on if the user is scrolling up/down the page, just like in the new Google's playstore app or NewsStand app. Is there something built into the toolbar widget for this or should I

wpf - Canvas control is not available in Windows form application?

WPF Canvas control is not available in Windows form application. Am using Visual Studio 2010. Framework 4.0. Is there way to add these controls to VS2010 toolbox?