【WPF系列】-TextBox常用点

 

高级实例:

通过dataTriger来给TextBox焦点

Using XAML to Set Focus on a Textbox in WPF Desktop Applications

【WPF系列】-TextBox常用点

<Style x:Key="LayoutRoot" TargetType="Grid">
        <Style.Triggers>
            <!--these are the triggers that make the code cursor jump from box 1 to box 2 to box 3.-->
            <DataTrigger Binding="{Binding ElementName=CodeDigit1, Path=Text.Length}" Value="1">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit2}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding ElementName=CodeDigit2, Path=Text.Length}" Value="1">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit3}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding ElementName=CodeDigit3, Path=Text.Length}" Value="1">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit4}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding ElementName=CodeDigit4, Path=Text.Length}" Value="1">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=ConnectButton}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

【WPF系列】-TextBox常用点

上一篇:PHP API反射实例


下一篇:windows2003远程桌面退出后系统自动注销的解决方法