1

I currently have a MainWindow containing a Modern UI MenuLinkGroup as in the following example:

<mui:ModernWindow.MenuLinkGroups>
  <mui:LinkGroup DisplayName="MenuItem1">
    <mui:LinkGroup.Links>
      <mui:Link DisplayName="Page 1" Source="/Sample1.xaml" />
    </mui:LinkGroup.Links>
  </mui:LinkGroup>
  <mui:LinkGroup DisplayName="MenuItem2">
    <mui:LinkGroup.Links>
      <mui:Link DisplayName="Page 1" Source="/Sample2.xaml" />
    </mui:LinkGroup.Links>
  </mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>

Then within Sample1.xml I am linking directly to Sample2.xml in the code behind which is in the different group. This works except the currently selected menu item at the top is still MenuItem1. Any ideas how I can set this please?

Hope this makes sense. Thanks in advance.

MattR
  • 13
  • 4

2 Answers2

1

the answer is to let ModernUI do the navigation.

In your button, try this -

<mui:ModernButton Content="Button" Command="mui:LinkCommands.NavigateLink"
 CommandParameter="/Sample1.xaml"/>
Rich Bryant
  • 865
  • 10
  • 27
0

What sense does Sample1.xaml have, when your are linking directly to Sample2.xaml?

A button, which link to Sample2.xaml, would solve your problem with the MenuLinkGroup.

Implement a button at Sample1.xaml like this:

                <mui:ModernButton Content="Button" Command="NavigationCommands.GoToPage" CommandParameter="/Sample1.xaml" CommandTarget="{Binding ElementName=frmContent}" />
L.P
  • 39
  • 8
  • @LP Thanks for the response but I already have a button like this in Sample1.xml (Sorry I did not describe it in enough detail, but thats what I meant by 'linking directly'). The button allows me to jump directly to Sample2.xml without clicking on the menu item. The problem is that the menulinkgroup does not reflect this change. So that even though the user is now looking at the correct page, the menu is still highlighting the previous page, Unless I am missing something in your suggestion (entirely possible)? – MattR Aug 31 '15 at 10:01
  • @MattR Maybe you have the same problem as in this question [link](http://stackoverflow.com/questions/28249707/modern-ui-how-to-go-to-another-page-from-another-link) from the past and you are also mixing "tab" with "page" navigation. Try out the following in your code behind `IInputElement target = FirstFloor.ModernUI.Windows.Navigation.NavigationHelper.FindFrame("_top", this); NavigationCommands.GoToPage.Execute("Sample2.xaml", target);` – L.P Sep 01 '15 at 06:19
  • Thanks again. I have already viewed and tried the suggestion from that post. But the "_top" frame returned is not the MainWindow but the containing Sample1.xml page. (Which is strange as I thought _top would go to the top of the frame tree). I will review my setup, perhaps I have something else wrong that is preventing the code working as it should. Thanks again for your help. – MattR Sep 01 '15 at 09:36