You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a PasswordBox,created by DialogHost.Then PasswordBoxAssist.Password binding is not working.
like this:
` var view = new SampleDialog
{
DataContext = new SampleDialogViewModel()
};
//show the dialog
var result = await DialogHost.Show(view, "RootDialog", null, ClosingEventHandler, ClosedEventHandler);`
SampleDialogViewModel.cs
`
public class SampleDialogViewModel : ViewModelBase
{
private string? _name;
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public string? number;
public string? Number
{
get => number;
set => SetProperty(ref number, value);
}
}`
Version
4.6.1
The text was updated successfully, but these errors were encountered:
@ChrisSun112 Unfortunately there seems to be a few issues with the PasswordBoxAssist.Password attached property. It works for many cases, but not for others; this being one of the cases where it does not work. I will end up refactoring it...
For now, you can mitigate the issue by simply giving the backing field a non-null value. So, in your sample above, you would change the definition of the backing field in the ViewModel from this:
privatestring?_name;
to this:
privatestring?_name=string.Empty;
@Keboo I think I will end up introducing Microsoft.Xaml.Behaviors which is what we initially discussed but I tried to avoid (to have fewer dependencies). I think it is needed in this case, because the current "initialization scheme" for the attached property value does not play nice with the DP precendence list in some scenarios. Using a behavior I believe will mitigate those issues. Are you OK with introducing this dependency?
Bug explanation
I have a PasswordBox,created by DialogHost.Then PasswordBoxAssist.Password binding is not working.
like this:
SampleDialog.xmal
<PasswordBox Grid.Row="1" wpf:HintAssist.HelperText="Name" wpf:HintAssist.Hint="Name" wpf:PasswordBoxAssist.Password="{Binding Path=Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" />
SampleDialogViewModel.cs
`
public class SampleDialogViewModel : ViewModelBase
{
Version
4.6.1
The text was updated successfully, but these errors were encountered: