I try to hide an object via the properties of another object I do not know what the problem is, but it does not work
Binding code
<StackPanel Orientation="Horizontal">
<Grid Margin="25,0,0,0" HorizontalAlignment="Center">
<TextBlock
Text="اسم المستخدم"
FontWeight="Light"
FontSize="18"
Foreground="White"
Background="Transparent"
Width="230"
Opacity="0.5"
Height="28"
Visibility="{Binding Path=VisbTbU , Mode=TwoWay}"/>
<TextBox
FontFamily="Helvetica"
FontWeight="Light"
FontSize="18"
HorizontalAlignment="Center"
Foreground="White"
Background="Transparent"
BorderThickness="0"
Width="235"
HorizontalContentAlignment="Left"
Opacity="0.5"
Height="25"
Text="{Binding UserLog}"
/>
</Grid>
<iconPacks:PackIconMaterial
Kind="Account"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Foreground="White"
/>
</StackPanel>
viewmodel code
public VmWinLogin()
{
VisbTbp = Visibility.Visible;
VisbTbp = Visibility.Visible;
UserLog = "";
UserPass = "";
}
private Visibility _VisbTbU ;
public Visibility VisbTbU
{
get => _VisbTbU;
set
{
_VisbTbU = value;
OnPropertyChanging();
}
}
private string _UserLog ;
public string UserLog
{
get => _UserLog .Trim();
set
{
_UserLog = value .Trim();
OnPropertyChanging();
if (_UserLog == "")
{
VisbTbU = Visibility.Visible;
}
else
{
VisbTbU = Visibility.Hidden;
}
}
}
basemodel code
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
{
PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
}
What I have tried:
I tried to follow the implementation to make sure the value of the property did not change and I found that it changed, but there is no effect on the object.