I dont want to see dotted lines in Button edges

Viewed 141

1- Create vb.net / wpf application.

2- Create three WPF Windows as Window1, Window2 and Window3

3- Copy and paste following xaml codes into MainWindow.

<Window x:Class="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">
<Grid>
    <StackPanel Width="180" Height="120">
        <Button x:Name="Button1" Height="30" Margin="5" Content="Button1"/>
        <Button x:Name="Button2" Height="30" Margin="5" Content="Button2"/>
        <Button x:Name="Button3" Height="30" Margin="5" Content="Button3"/>
    </StackPanel>
</Grid>
</Window>

4- Copy and paste following vb.net codes into MainWindow code behind.

Class MainWindow

Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
    Dim myWindow1 As New Window1()
    myWindow1.Show()
End Sub

Private Sub Button2_Click(sender As Object, e As RoutedEventArgs) Handles Button2.Click
    Dim myWindow2 As New Window2()
    myWindow2.Show()
End Sub

Private Sub Button3_Click(sender As Object, e As RoutedEventArgs) Handles Button3.Click
    Dim myWindow3 As New Window3()
    myWindow3.Show()
End Sub

Private Sub MainWindow_KeyDown(sender As System.Object, e As System.Windows.Input.KeyEventArgs) Handles MyBase.KeyDown
    If e.Key = Key.F1 Then
        Dim myWindow1 As New Window1()
        myWindow1.Show()
    End If

    If e.Key = Key.F2 Then
        Dim myWindow2 As New Window2()
        myWindow2.Show()
    End If

    If e.Key = Key.F3 Then
        Dim myWindow3 As New Window3()
        myWindow3.Show()
    End If
End Sub

End Class

5- Run this project, then click Button2, then close Window2, then press F3, then close Window3

My question:

I dont want to see dotted lines in Button edges as you can see here https://prnt.sc/lz8856

1 Answers

This dotted lines is your focus. There is defferent ways to get rid of it.

  1. Set IsTabStop="False" for your button in XAML, then it will be skipped when you [Tab] over your buttons but will hold user focus after mouse click. So, for example, after mouse click, you can press this button by [Space bar].

  2. Set Focusable="False" for your button in XAML, then it will be skipped when you [Tab] over your buttons and will NOT hold user focus after mouse click.

  3. Set FocusVisualStyle="{x:Null}" for your button in XAML, then it just remove this line, and your tab order and focus holding will remain the same.

Related