Microsoft KB Archive/937134

= BUG: The NavigatingCancelEventArgs.IsNavigationInitiator property or the NavigationEventArgs.IsNavigationInitiator property incorrectly returns a value of False in the .NET Framework 3.0 =

Article ID: 937134

Article Last Modified on 6/27/2007

-

APPLIES TO


 * Microsoft .NET Framework 3.0

-





SYMPTOMS
In the Microsoft .NET Framework 3.0, one or both of the following properties incorrectly return a value of False in a Windows Presentation Foundation (WPF) program:
 * NavigatingCancelEventArgs.IsNavigationInitiator
 * NavigationEventArgs.IsNavigationInitiator



CAUSE
This issue occurs when a Frame class content control is configured to record navigations in its own journal instead of recording navigations in the parent navigator's journal.



WORKAROUND
To work around this issue, assume that the value for the IsNavigationInitiator property is true in each scenario that is described in the &quot;More Information&quot; section.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For example, this issue can occur when the JournalOwnership property is configured to use the OwnsJournal value. Or, this issue can occur when a Frame control is hosted in a Window object and not in a NavigationWindow object. In this scenario, the Frame control automatically creates its own journal.

When a Frame class navigating event is initiated, the Frame content control raises the Navigating event before navigation. A NavigatingCancelEventArgs argument is passed to the Frame.Navigating event handler. The NavigatingCancelEventArgs argument implements the IsNavigationInitiator property to report whether the Frame content control initiated the navigation or whether a higher-level Frame content control or a NavigationWindow object is navigating.

A Frame control can have its own navigation journal. This frame is also known as an &quot;island frame.&quot; When a Frame control has its own navigation journal, the IsNavigationInitiator property is always reported as False.

Additionally, the NavigationEventArgs.IsNavigationInitiator property may incorrectly return of value of False because the NavigationEventArgs class is passed as an argument to the Frame.Navigated event.



Steps to reproduce the problem
 Start Visual Studio 2005. Create a new .NET Framework 3.0 Windows Application (WPF) project that is named IsNavigationInitiatorDemo. In Solution Explorer, right-click IsNavigationInitiatorDemo, click Add, and then click New Item. Click Page (WPF), type Page1 in the Name box, and then click Add. In Solution Explorer, right-click IsNavigationInitiatorDemo, click Add, and then click New Item.</li> Click Page (WPF), type Page2 in the Name box, and then click Add.</li>  Add the following code to Page 1.xaml: <Page x:Class=&quot;WindowsApplication1.Page1&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; > <Hyperlink NavigateUri=&quot;Page2.xaml&quot;>Page 2</Hyperlink> </Page> </li>  Add the following code to Window1.xaml: <Window x:Class=&quot;WindowsApplication1.Window1&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; > <Frame Name=&quot;frame&quot; Source=&quot;Page1.xaml&quot; /> </Window> </li>  Add the following code to handle the Frame.Navigating event to inspect the NavigatingCancelEventArgs.IsNavigationInitiator property: public partial class Window1 : Window { public Window1 { InitializeComponent;

this.frame.Navigating += new System.Windows.Navigation.NavigatingCancelEventHandler(frame_Navigating); }

void frame_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e) { // e.IsNavigationInitiator returns false although should return true Debug.WriteLine(&quot;frame.IsNavigationInitiator=&quot; + e.IsNavigationInitiator.ToString); } } </li> Build the project. Then, click the hyperlink on Page1.xaml.</li></ol>

<div class="references_section">