3

I want to encapsulate frame navigation in custom command und use this command declaratively as a static ressource. I found

Frame.Navigate(typeof(MainPage));

which expects a type parameter (type of the target page) to navigate to. My first attempt was to use a generic ICommand implementation that passes the type of the target page as generic type parameter. As of x:TypeArguments is not supported for Windows Store Apps, I tried to define a property

public Type TargetType { get; set; }

for the command. But no luck again: if I try to set the property via a xaml attribute

`<NavigationCommand TargetType="MainPage">

I get a compile-time error saying

MainPage is not supported in a Windows universal project
Community
  • 1
  • 1
ventiseis
  • 3,029
  • 11
  • 32
  • 49

1 Answers1

3

This should work:

<NavigationCommand TargetType="ns:MainPage">

Where ns is an XML namespace prefix declared with xmlns:ns="using:TheNamespaceInCode"

(note: the x:Type markup extension used in WPF isn't supported in WinRT)

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758