public void openButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.DefaultExt = ".rtf"; open.Filter = "Rich Text files (*.rtf)|*.rtf|All files (*.*)|*.*"; if (textChanged == true) { toSave(); } System.Windows.Forms.DialogResult result = open.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { ClearText(); TextBlock1.AppendText(System.IO.File.ReadAllText(open.FileName)); textChanged = false; currentFileName = open.FileName; } }
public void WriteToTextBlock(string message) { TextBlock1.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { TextBlock1.AppendText(message + "\n"); })); }