Ejemplo n.º 1
0
		static void OnIsReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			TextEditor editor = d as TextEditor;
			if (editor != null) {
				if ((bool)e.NewValue)
					editor.TextArea.ReadOnlySectionProvider = ReadOnlyDocument.Instance;
				else
					editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance;
				
				TextEditorAutomationPeer peer = TextEditorAutomationPeer.FromElement(editor) as TextEditorAutomationPeer;
				if (peer != null) {
					peer.RaiseIsReadOnlyChanged((bool)e.OldValue, (bool)e.NewValue);
				}
			}
		}
Ejemplo n.º 2
0
        static void OnIsReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is TextEditor editor)
            {
                if ((bool)e.NewValue)
                {
                    editor.TextArea.ReadOnlySectionProvider = ReadOnlySectionDocument.Instance;
                }
                else
                {
                    editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance;
                }

                if (TextEditorAutomationPeer.FromElement(editor) is TextEditorAutomationPeer peer)
                {
                    peer.RaiseIsReadOnlyChanged((bool)e.OldValue, (bool)e.NewValue);
                }
            }
        }