File Activation in Windows RT

Posted by jdanforth on ASP.net Weblogs See other posts from ASP.net Weblogs or by jdanforth
Published on Fri, 23 Nov 2012 10:57:32 GMT Indexed on 2012/11/23 11:01 UTC
Read the original article Hit count: 221

Filed under:
|
|
|
|
|

The code sample for file activation on MSDN is lacking some code Winking smile so a simple way to pass the file clicked to your MainPage could be:

protected override void OnFileActivated(FileActivatedEventArgs args)

{

    var page = new Frame();

    page.Navigate(typeof(MainPage));

    Window.Current.Content = page;

 

    var p = page.Content as MainPage;

    if (p != null) p.FileEvent = args;

    Window.Current.Activate();

}

And in MainPage:

public MainPage()

{

    InitializeComponent();

    Loaded += MainPageLoaded;

}

void MainPageLoaded(object sender, RoutedEventArgs e)

{

    if (FileEvent != null && FileEvent.Files.Count > 0)

    {

        //… do something with file

    }

}

© ASP.net Weblogs or respective owner

Related posts about window

Related posts about c