Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6230125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:41:30+00:00 2026-05-24T09:41:30+00:00

The focus visual hint that wpf provides on Windows 7 is a dashed line,

  • 0

The focus visual hint that wpf provides on Windows 7 is a dashed line, as such this:
FocusExample

Now, how can I change the way it looks? How can I control its appearence?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:41:31+00:00Added an answer on May 24, 2026 at 9:41 am

    Try something like following

    <Window x:Class="FocusVisualStyle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="MyFocusVisualStyle">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Margin="-2" StrokeThickness="1" Stroke="Red"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <StackPanel Orientation="Horizontal" Height="24">
        <TextBox Width="96"/>
        <Button Content="Yes" Width="64" FocusVisualStyle="{DynamicResource MyFocusVisualStyle}"/>
        <Button Content="No" Width="64" FocusVisualStyle="{DynamicResource MyFocusVisualStyle}"/>
    </StackPanel>
    

    You can customise to suit your liking. This is just a starting point.

    Edit: Since so many people have liked this solution here is another example which changes focus visual style for all buttons and textboxes without explicit setting of FocusVisualStyle property for each control (see that DynamicResource thingy?) in xaml

    Also it uses animation to change the colour of the focus rectangle.

    Enjoy 🙂

    <Window x:Class="FocusVisualStyle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="MyFocusVisualStyle">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate >
                        <Rectangle Margin="-2" StrokeThickness="2" RadiusX="2" RadiusY="2" >
                            <Rectangle.Stroke>
                                <SolidColorBrush Color="Red" x:Name="RectangleStroke" />
                            </Rectangle.Stroke>
                            <Rectangle.Triggers>
                                <EventTrigger RoutedEvent="Rectangle.Loaded" >
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <ColorAnimation From="Red"
                                                            To="Orange"
                                                            Duration="0:0:0.5" 
                                                            RepeatBehavior="Forever" 
                                                            Storyboard.TargetName="RectangleStroke"
                                                            Storyboard.TargetProperty="Color"/>
                                            <DoubleAnimation To="3" 
                                                             Duration="0:0:0.5"
                                                             RepeatBehavior="Forever"
                                                             Storyboard.TargetProperty="StrokeDashOffset" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                            </Rectangle.Triggers>
                        </Rectangle>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    
        <Style TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisualStyle}" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisualStyle}" />
        </Style>
    </Window.Resources>
    <StackPanel Orientation="Horizontal" Height="24">
        <TextBox Width="96"/>
        <Button Content="Yes" Width="64" />
        <Button Content="No" Width="64" />
    </StackPanel>
    

    Here you see that I have styles for Button and TextBox which set the property FocusVisualStyle for all the buttons and text boxes in this window.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented a custom list view, but now there's no visual feedback that an
In Visual Studio 2008, is there any way to change the background color of
In Visual Studio 2010, I have a Database Project. I can use this without
How can focus the controls when select a tabitem in a tabcontrol?
How can I remove focus from submit button? I don't know why it is
$('#div1').focus(function () { callAnotherFunction(); $(this).animate({}); } I'm trying to make $(this).animate({}); execute after callAnotherFunction();
In visual studios i can run code analysis on my .NET project. I am
I have an application that started life as an MVC (1.0) app in Visual
private void screensaverWindow_Load(object sender, System.EventArgs e) { this.BringToFront(); this.Focus(); this.KeyPreview = true; this.KeyDown +=
My Question: Is there a way to set up Visual Studio to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.