I have a button on my Xaml page that its visibility is binded to a variable of Type : SYSTEM.Windows.Visibility
in the view model, for the first time the page is loaded whether I set the variable to Hidden or Visible , it works fine. but aftre doing some operation when I change the variable to other status my GUI doesn't update.
Here are my xaml and MVVM
<Button Content="Extend" Name="btnExtend" Command="{Binding ExtendCommand}" Visibility="{Binding isVisible}" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" Width="80" Margin="0,0,100,0" Height="25"/>
and view model :
Public Property isVisible As System.Windows.Visibility
Public Sub New()
isVisible = System.Windows.Visibility.Visible
End Sub
Public Sub diable()
isVisible = System.Windows.Visibility.Visible
End Sub
I read in some topics to change the variable to Boolean
and use a BooleanToVisibilityConverter
, I tried this too, but the result was the same.
I really don't get it what I do wrong.
your xaml code should be
<Button Content="Extend" Name="btnExtend" Command="{Binding ExtendCommand}" Visibility="{Binding isVisible,Mode=Twoway}" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" Width="80" Margin="0,0,100,0" Height="25"/>
and your Viewmodel Code Should be
private Visibility _isVisible ;
public Visibility isVisible
{
get { return _isVisible ;}
set { _isVisible = value;RaisePropertyChanged("isVisible ");}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With