Christian
Christian

Reputation: 26387

Opening the start page after opening Xamarin UWP app via File Type Associations

I have registered a File Type Associations to open my custom fileformat .xoip. When I'm opening a .xoip file the OnFileActivated-function in the App class gets started but no MainPage gets created.

Depending on the contact of the file, I want to decide in the OnFileActivated-function whether or not to start my start page. What do I have to call to start the start page?

Upvotes: 0

Views: 141

Answers (1)

Dishant
Dishant

Reputation: 1595

With File Type Association you need to manually specify what page to be loaded when a particular file is open.

When any associated file is activated it will call OnFileActivated of your App.xaml.cs. You can add your logic to navigate to a particular page in that method. Please refer to below code:

protected override void OnFileActivated(FileActivatedEventArgs args)
{
   base.OnFileActivated(args);
   var rootFrame = new Frame();
   rootFrame.Navigate(typeof(MainPage), args);
   Window.Current.Content = rootFrame;
   Window.Current.Activate();
}

Upvotes: 2

Related Questions