Hi all of you, I've got a couple of issues with the focus of my view.
I wonder whether related with PasswordBox control or not
The first issue:
<PasswordBox Margin="48,14,56,14" x:Name="pwdnou"
FocusManager.FocusedElement="{Binding ElementName=pwdnou}"
PasswordChanged="pwdnou_PasswordChanged"
Grid.ColumnSpan="2" Grid.Column="1" Foreground="MidnightBlue" BorderBrush="Gray"
HorizontalAlignment="Center" VerticalAlignment="Center" Height="24" Width="100" />
<PasswordBox Margin="48,14,56,14" x:Name="pwdnouconfirmar"
Style="{StaticResource PasswordBoxVistaStyle}"
LostFocus="pwdnouconfirmar_LostFocus"
Grid.ColumnSpan="2" Grid.Column="1" Foreground="MidnightBlue" BorderBrush="Gray"
HorizontalAlignment="Center" VerticalAlignment="Center" Height="24" Width="100" Grid.Row="1" />
It does not work at all; when I load my view I don't see the cursor on "pwdnou" PasswordBox, in fact, the cursor is not visible at all.
Nevertheless if I write pwdnou.Focus() in OnLoaded Grid event code-behind it does works properly. But I don't like to use code-behind for that.
The second one is when I try to set the focus in that same PasswordBox from the Lostfocus event on the second one PasswordBox (pwdnouconfirmar). Here, amazingly does not work.
What am I missing here?
Private Sub pwdnouconfirmar_LostFocus(sender As Object, e As RoutedEventArgs) If pwdnou.Password <> pwdnouconfirmar.Password Then sMessageTranslated = My.Resources.MasterGIT.APP_ERROR3 WpfMessageBox.Show(sMessageTranslated, Conectividad.NameOfApplication, WpfMessageBoxButton.OK, WpfMessageBoxImage.Error) pwdnou.Password = String.Empty pwdnouconfirmar.Password = String.Empty ' pwdnou.Focusable = True pwdnou.Focus() 'Exit Sub End If
Thanks in advance for any input or hint provided
Primary platform is Windows 7 Ultimate 64 bit along with VS 2012/Sql2k8 for WPF/SilverLight projects.