wpf 窗口打開后默認設置控件焦點


https://blog.csdn.net/Vblegend_2013/article/details/81771872

 

<Grid FocusManager.FocusedElement="{Binding ElementName=pwd}">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<Button Style="{StaticResource CloseImageButtonStyle}" HorizontalAlignment="Right"
Margin="0,0,5,0"
IsCancel="True"
Command="{Binding CloseCommand}" />
<DockPanel Margin="45,0" Grid.RowSpan="2" VerticalAlignment="Center">
<Button
IsDefault="True"
DockPanel.Dock="Right" Margin="10,0,0,0" Style="{StaticResource NormalButtonStyle}" Content="確定"
Command="{Binding ConfirmCommand}" />

<PasswordBox
x:Name="pwd"
converter:PasswordBoxHelper.Password="{Binding Password,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Height="30" Style="{StaticResource DefaultPasswordBoxStyle}" />
</DockPanel>
</Grid>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM