예제 #1
0
        private void Model_SyncRequested(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            ProgramCodeViewModel model = MyEditor.DataContext as ProgramCodeViewModel;

            if (e.PropertyName == nameof(model.Code))
            {
                model.Code = MyEditor.Text;
            }
        }
예제 #2
0
        private void TextEditor_Loaded(object sender, RoutedEventArgs e)
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                ProgramCodeViewModel model = MyEditor.DataContext as ProgramCodeViewModel;

                using (Stream stream = GetResourceStream("python.xshd"))
                {
                    MyEditor.SyntaxHighlighting =
                        HighlightingLoader.Load(new XmlTextReader(stream),
                                                HighlightingManager.Instance);
                }

                MyEditor.Text = model.Code;

                model.SyncRequested += Model_SyncRequested;

                model.PropertyChanged += Model_PropertyChanged;
            }
        }