wpf - Function call within XAML code? -


I think that you want to set a style all my text box control the following when the keyboard focus :

<:>

1) background color
2) to highlight all the text

I have this amount so far. SelectAll () Change calls pre> & gt; Style target type = "text box" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "IsKeyboardFocusWithin" value = "true" & gt; & Lt; Setter Property = "Background" & gt; & Lt; Setter.Value & gt; & Lt; Solid color brush color = "#fffd1d9" /> & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;

Is there a way to call also. Select () ? Thank you.

You can do this through the attached behavior.

Example

  public static class TextBoxBehaviour {GetSelectAll (TextBoxBase target) {return (bool) target.GetValue (SelectAllAttachedProperty) bool public static; } Public static Zero SetSelectAll (Text BoxBase Target, Boole Value) {target.SetValue (SelectAllAttachedProperty, Value); } Public static DependencyProperty SelectAllAttachedProperty = DependencyProperty.RegisterAttached ( "SelectAll", typeof (bool), typeof (TextBoxBehaviour), New UIPropertyMetadata (wrong, OnSelectAllAttachedPropertyChanged)) read-only; static void OnSelectAllAttachedPropertyChanged (DependencyObject o, DependencyPropertyChangedEventArgs e) {((TextBoxBase) o) .SelectAll (); }}  

Usage

  & lt; Style TargetType = "{x: type text box}" xmlns: behavior = "clr -namespace: Controls.Behaviours" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "IsKeyboardFocusWithin" value = "true" & gt; & Lt; Setter Property = "Background" Value = "#FFFFD1D9" /> & Lt; Setter property = "behavior: text box. Select." Value = "true" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;  

reference

NB: Was not able to check up Implementation, in principle though it should only work

hH,


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -