I want make a notepad. But I have problem with function Open file. This is my code:
private void MenuItem_Click_Open(object sender, RoutedEventArgs e)
{
FlowDocument myFlowDoc = new FlowDocument();
OpenFileDialog opf = new OpenFileDialog();
opf.Filter = filtr;
if (opf.ShowDialog() == true)
{
StreamReader sr = new StreamReader(opf.FileName);
FlowDocument doc = XamlReader.Parse(sr.ReadToEnd()) as FlowDocument;
richTextBox1.Document = doc;
this.Title = System.IO.Path.GetFileName(opf.FileName);
sr.Close();
}
}
Problem manifests itself in here:
FlowDocument doc = XamlReader.Parse(sr.ReadToEnd()) as FlowDocument;
The error message is given in the title this post. Thanks for any help!

New Topic/Question
Reply



MultiQuote




|