private async void LoadTextFile(int id) { try { if (id == -1) { m_textFile = m_repository.NewFile(); } else { m_textFile = await m_repository.FileById(id); } m_textFile.IsDirty = false; m_text.DataContext = m_textFile; Title = string.Format("TextEditor - {0}", string.IsNullOrEmpty(m_textFile.Name) ? "*" : m_textFile.Name); m_textFile.PropertyChanged += TextFileBecomeDirtyHandler; } catch (Exception exc) { MessageBox.Show(this, exc.Message + "\n" + exc.StackTrace, "Exception on loading text file", MessageBoxButton.OK, MessageBoxImage.Error); } }