I am using the OnFileActive for when I open a file with the "Open With and I choose my program" because it opens and its text is loaded in the RichEditBox and its path appears in the title of the Notepad-style app, then everything goes well since with the function that I put in the MainPage the path is put in the title, I read it and load it in the RichEditBox use the same code that I use with a button that I put with a File Picker that loads it also, but for some reason it does not load it to the RichEditBox. I tried instead of loading the RichEditBox I put it in a MessageDialog and there if they showed it then I do not understand why the RichEditBox does not load it. The code that will show will be OnNavigatedTo in App.xalm.cs and the function in Main.xalm.cs.
async void OnNavigatedTo(object sender, NavigationEventArgs e)
{
var args = e.Parameter as Windows.ApplicationModel.Activation.IActivatedEventArgs;
if (args != null)
{
if (args.Kind == Windows.ApplicationModel.Activation.ActivationKind.File)
{
var fileArgs = args as Windows.ApplicationModel.Activation.FileActivatedEventArgs;
string strFilePath = fileArgs.Files[0].Path;
var file = (StorageFile)fileArgs.Files[0];
await new MainPage().LoadTextFile(file);
}
}
}
And the function in the Main.xalm.cs
public async Task LoadTextFile(StorageFile file)
{
string text = await FileIO.ReadTextAsync(file);
rbText.Document.SetText(TextSetOptions.None, text);
current_path = file.Path;
current_file = file.Name;
var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.Title = current_path;
}