static DionysusTextBox() { //For the IsReadOnly dependency property IsReadOnlyProperty.OverrideMetadata( //On the type DionysusTextBox typeof(DionysusTextBox), //Redefine default behavior new FrameworkPropertyMetadata( //Default value, can also omit this parameter null, //When IsReadOnly changed, this is executed new PropertyChangedCallback( (dpo, dpce) => { //dpo hold the DionysusTextBox instance on which IsReachOnly changed //dpce.NewValue hold the new value of IsReadOnly //Run logic to set the background here, you are on the UI thread. //Example of setting the BorderBrush from ARGB values: var dioBox = dpo as DionysusTextBox; //Should always be true, of course, it's just my OCD ;) if (dioBox != null) { dioBox.BorderBrush = ColorConverter.ConvertFromString("#FFDDDDDD") as Color; } }))); }
static EditableTextBlock() { DefaultStyleKeyProperty.OverrideMetadata(typeof(EditableTextBlock), new FrameworkPropertyMetadata(typeof(EditableTextBlock))); IsReadOnlyProperty.OverrideMetadata(typeof(EditableTextBlock), new FrameworkPropertyMetadata(true)); CursorProperty.OverrideMetadata(typeof(EditableTextBlock), new FrameworkPropertyMetadata(Cursors.Hand)); TextProperty.OverrideMetadata(typeof(EditableTextBlock), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnTextChanged))); //FocusableProperty.OverrideMetadata(typeof(EditableTextBlock), new FrameworkPropertyMetadata(false)); }
// ! TextBlock public static void Bind(TextBlock tb) { var textContainer = TextContainerProperty.GetValue(tb); var editor = new InternalTextEditorHacker(textContainer, tb, false); IsReadOnlyProperty.SetValue(editor._internalTextEditor, true); TextViewProperty.SetValue(editor._internalTextEditor, TextContainerTextViewProperty.GetValue(textContainer)); }
/// <summary> /// Initializes the <see cref="TextBox"/> type. /// </summary> static TextBox() { EventManager.RegisterClassHandler(typeof(TextBox), ScrollViewer.ScrollChangedEvent, new UpfScrollChangedEventHandler(HandleScrollChanged)); HorizontalScrollBarVisibilityProperty.OverrideMetadata(typeof(TextBox), new PropertyMetadata <ScrollBarVisibility>(ScrollBarVisibility.Hidden, null, CoerceHorizontalScrollBarVisibility)); IsReadOnlyProperty.OverrideMetadata(typeof(TextBox), new PropertyMetadata <Boolean>(HandleIsReadOnlyChanged)); }
static SearchBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(typeof(SearchBox))); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); IsEditableProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(true)); IsReadOnlyProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(false)); ShouldPreserveUserEnteredPrefixProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(true)); StaysOpenOnEditProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(true)); IsTabStopProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(false)); IsDropDownOpenProperty.OverrideMetadata(typeof(SearchBox), new FrameworkPropertyMetadata(OnIsDropDownOpenChanged)); }
/// <summary> /// スタティックコンストラクタ /// </summary> static ExTextBox() { //依存関係プロパティのメタデータのオーバーライド //IsReadOnlyプロパティが変更された時の動作 IsReadOnlyProperty.OverrideMetadata( typeof(ExTextBox) , new FrameworkPropertyMetadata( false , (sender, e) => { ExTextBox textBox = sender as ExTextBox; if (textBox == null) { return; } MessageBox.Show(textBox.IsReadOnly.ToString()); })); }
static DionysusTextBox() { //For the IsReadOnly dependency property IsReadOnlyProperty.OverrideMetadata( //On the type DionysusTextBox typeof(DionysusTextBox), //Redefine default behavior new FrameworkPropertyMetadata( //Default value, can also omit this parameter null, //When IsReadOnly changed, this is executed new PropertyChangedCallback( (dpo, dpce) => { //dpo hold the DionysusTextBox instance on which IsReachOnly changed //dpce.NewValue hold the new value of IsReadOnly //Run logic to set the background here, you are on the UI thread. }))); }
set => SetValue(IsReadOnlyProperty, value);
static TextBox() { IsReadOnlyProperty.AddPropertyChangeCallback(IsReadOnlyChanged); TextProperty.AddPropertyChangeCallback(TextPropertyChanged); }
static SmartGrid() { IsReadOnlyProperty.OverrideMetadata(typeof(SmartGrid), new FrameworkPropertyMetadata((o, e) => ((SmartGrid)o).ConfigureColumns())); CommandManager.RegisterClassCommandBinding(typeof(SmartGrid), new CommandBinding(ApplicationCommands.Paste, (o, e) => ((SmartGrid)o).OnExecutedPaste())); }
/// <summary> /// Constructor</summary> static FormattingTextBox() { IsReadOnlyProperty.OverrideMetadata(typeof(FormattingTextBox), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits, IsReadOnlyChanged)); }
set => this.SetValue(IsReadOnlyProperty, value);