【发布时间】:2025-12-22 08:55:12
【问题描述】:
1- 创建 vb.net / wpf 应用程序。
2- 创建三个 WPF 窗口,分别为 Window1、Window2 和 Window3
3- 将以下 xaml 代码复制并粘贴到 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- 将以下 vb.net 代码复制并粘贴到 MainWindow 代码后面。
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- 运行这个项目,然后点击Button2,然后关闭Window2,然后按F3,然后关闭Window3强>
我的问题:
我不想在按钮边缘看到虚线,如您在此处看到的 https://prnt.sc/lz8856
【问题讨论】:
-
这就是你的“标签索引”在 button2 上的原因吗?将您的“TabIndex”位置更改为不同的控件。