Windowstemplatestudio: WinUI:NavigationView does not navigate in Release Mode

Created on 27 Nov 2018  路  12Comments  路  Source: microsoft/WindowsTemplateStudio

Hi , something I noticed , the Hamburger menu items does not change the page views when app is build to UWP Release Mode.

releasemode1

Using latest stable VS 15.9.2
ts

bug

All 12 comments

@Pinox can you share the 'recipe' you used to aid us in debugging?

@crutkas Sure, Navigation Menu , Mvvmlight and then I had a couple of random pages as in screenshot above.

@pinox, we're having a look at this.
The issue seems to be related to using the EventTriggerBehavior on the ItemInvoked event.

While we are working on a fix you can workaround by using the event instead.
In ShellPage.xaml, remove the following code:

<ic:EventTriggerBehavior EventName="ItemInvoked">
         <ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
 </ic:EventTriggerBehavior>

and add

ItemInvoked="NavigationView_ItemInvoked"

In the ShellPage.xaml.cs add:

private void NavigationView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
     ViewModel.ItemInvokedCommand.Execute(args);
}

@sibille Thanks.

Will this need a hot fix?

Created an issue to investigate this at https://github.com/Microsoft/XamlBehaviors/issues/142. I think we should prepare a hotfix with the workaround while investigating the root cause.

Hotfix published

I see that you've moved away from the XAML Behaviors with this hotfix, but in case you still want to use it, I have a solution for you!

On the "Default.rd.xml" template files, add the following directives:

<Type Name="Windows.Foundation.TypedEventHandler{Microsoft.UI.Xaml.Controls.NavigationView,Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs}" MarshalObject="Public" />

<Type Name="Microsoft.UI.Xaml.Controls.NavigationView">
  <Event Name="ItemInvoked" Dynamic="Required"/>
</Type>

This will be enough to ensure that NavigationView.ItemInvoked event can be used dynamically with reflection (in this case, with the EventTriggerBehavior)

Oooo. Thanks Pedro. Sibille, thoughts?

I think we should re-include the behaviour and the directives in the Default.rd.xml file, adding a comment that explains what they are needed for.

Verified in dev-nightly:
Templates version: 0.20.19009.3
Wizard version: 0.20.19009.1

Was this page helpful?
0 / 5 - 0 ratings