async void OnOpenAppBarButtonClick(object sender, RoutedEventArgs args) { FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".txt"); picker.FileTypeFilter.Add(".rtf"); StorageFile storageFile = await picker.PickSingleFileAsync(); // If user presses Cancel, result is null if (storageFile == null) { return; } TextSetOptions textOptions = TextSetOptions.None; if (storageFile.ContentType != "text/plain") { textOptions = TextSetOptions.FormatRtf; } string message = null; try { IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.Read); richEditBox.Document.LoadFromStream(textOptions, stream); } catch (Exception exc) { message = exc.Message; } if (message != null) { MessageDialog msgdlg = new MessageDialog("The file could not be opened. " + "Windows reports the following error: " + message, "RichTextEditor"); await msgdlg.ShowAsync(); } }
public void SetText(TextSetOptions options, string value) { throw new NotImplementedException(); }
public void LoadFromStream(TextSetOptions options, Windows.Storage.Streams.IRandomAccessStream value) { throw new NotImplementedException(); }