Highlight a WPF control when it gets focus

I am working on a WPF application that has many screens and there are many controls on each screen. It is very difficult to determine which control is concentrated.

So, I want to highlight the control that is currently focused on it. It can be text fields, buttons, drop-down lists, list or grid.

It would be better if we can use this with styles and triggers.

thank

+5
source share
3 answers

You must use a trigger for the correct event. In your case it is IsFocused. A simple example:

<Trigger Property="IsFocused" Value="true">
    <Setter Property="BorderBrush" Value="Red" />
    <Setter Property="BorderThickness" Value="1" />
</Trigger>

Style, specific (, TargetType="{x:Type TextBox}").

, , BasedOn: <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource BaseFocusStyle}">

, , SO: " Style.Triggers , .

+7

. . , MSDN , Focused . MSDN .

0

All Articles