public XamlRichTextEditor() { InitializeComponent(); Unloaded += (sender, args) => { TextBox.UpdateXaml(); }; _factory = new UniqueWindowFactory <SeparateTextEditorWindow>(() => { var rtfRichTextEditor = new XamlRichTextEditor { Width = ActualWidth, Height = ActualHeight, }; rtfRichTextEditor.SetBinding(XamlTextProperty, new Binding { Source = this, Path = new PropertyPath(nameof(XamlText)), Mode = BindingMode.TwoWay }); rtfRichTextEditor.EditorFormatShown = true; var window = new SeparateTextEditorWindow(rtfRichTextEditor); var widthBind = new Binding(nameof(Width)) { Source = this, Mode = BindingMode.OneWay }; var heightBind = new Binding(nameof(Height)) { Source = this, Mode = BindingMode.OneWay }; rtfRichTextEditor.SetBinding(WidthProperty, widthBind); rtfRichTextEditor.SetBinding(HeightProperty, heightBind); window.Loaded += (o, args) => { rtfRichTextEditor.TextBox.UpdateMode = UpdateMode.TextInput; var widthBindTwo = new Binding(nameof(Width)) { Source = this, Mode = BindingMode.TwoWay }; var heightBindTwo = new Binding(nameof(Height)) { Source = this, Mode = BindingMode.TwoWay }; rtfRichTextEditor.SetBinding(WidthProperty, widthBindTwo); rtfRichTextEditor.SetBinding(HeightProperty, heightBindTwo); }; return(window); }, this); }
public MainWindow() { ModifyProvider = new DelegateInteractionProvider <IModifyObjectInteraction>(() => new ModifyObjectWindow(this)); InitializeComponent(); PropertyChangedObject.RegisterWindow(this); DataContextChanged += OnDataContextChanged; DataContext = new MainWindowViewModel(); _pageViewerFactory = new UniqueWindowFactory <PageCollectionViewerWindow>(() => new PageCollectionViewerWindow((MainWindowViewModel)DataContext), this, hideInsteadOfClose: true); Canvas.DefaultDrawingAttributes.FitToCurve = true; ContentRendered += (_, __) => { Dispatcher.BeginInvoke(new Action(() => { foreach (var error in App.ErrorQueue) { MessageBox.Show(this, error, ErrorResources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } }), DispatcherPriority.ApplicationIdle); }; }