Skip to content

FocusManager.FocusedElement 无法让 NumericUpDown 聚焦 #1788

Description

@qianshipoi

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions