HandyOrg / HandyOrg/HandyControl
FocusManager.FocusedElement 无法让 NumericUpDown 聚焦
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
使用 FocusManager.FocusedElement 没有办法让 NumericUpDown 一开始就聚焦
Steps to reproduce the bug
代码
<Window
x:Class="WpfApp6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:WpfApp6"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="800"
Height="450"
FocusManager.FocusedElement="{Binding ElementName=Input}"
mc:Ignorable="d">
<Grid>
<hc:NumericUpDown
x:Name="Input" Focusable="True"
Width="120"
VerticalAlignment="Center" />
</Grid>
</Window>
Expected behavior
应该会在窗口打开时自动聚焦到文本框
Screenshots
No response
NuGet package version
HandyControl 3.5.1
IDE
Visual Studio 2022-preview
Framework type
.Net 9.0
Windows version
No response
Additional context
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Window XAML and the HandyControl NumericUpDown control, reproducing the issue on .NET 9 with HandyControl 3.5.1. Trace how FocusManager.FocusedElement interacts with the control during window startup. Done means the NumericUpDown receives focus automatically when the window opens, with the reported XAML scenario working as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100