简体   繁体   中英

Binding progressbar visibility mvvm not working

sorry for my bad english :x

I use MVVM Light toolkit on my project and i try to collapsed and restored a progressbar but i have used a lot of snippet and browse a lot of forums around this subject and i can not solve my problem.

My Home.xaml

<ProgressBar Minimum="0" Maximum="100" Height="16" IsIndeterminate="True" Visibility="{Binding ProgressBarVisibility}"/>

My HomeViewModel :

    private System.Windows.Visibility progressBarVisibility;

    public System.Windows.Visibility ProgressBarVisibility
    {
        get { return progressBarVisibility; }
        set
        {
            progressBarVisibility = value;
            RaisePropertyChanged("ProgressBarVisibility");
        }
    }

    /// <summary>
    /// Initializes a new instance of the HomeViewModel class.
    /// </summary>
    public HomeViewModel()
    {
        this.ContentStatutBar = "Recherche de mises à jour en cours";
        this.ProgressBarVisibility = Visibility.Visible;
        this.DownButtonVisibility = System.Windows.Visibility.Collapsed;

        this.flag = false;

        this.fakeButtonAction = new RelayCommand(() => this.update());
    }

    public void update()
    {
        if (!this.flag)
        {
            this.flag = true;

            this.ContentStatutBar = "Une mise à jour en attente";
            this.progressBarVisibility = Visibility.Collapsed;
            this.DownButtonVisibility = System.Windows.Visibility.Visible;
        }
        else
        {
            this.flag = false;

            this.ContentStatutBar = "Aucune mises à jour";
            this.progressBarVisibility = Visibility.Visible;
            this.DownButtonVisibility = System.Windows.Visibility.Collapsed;
        }

        this.ContentStatutBar = this.DownButtonVisibility.ToString();
    }

When i use my update method in my Home.xaml.cs it's work (not binding --> (progressbar.Visibility = Visibility.Visible)) but when i try to use this by binding in my VM it's don't work :[

Can you help me please ?

Best Regards ;)

您正在更改字段,请使用更新方法更新属性

      this.ProgressBarVisibility = Visibility.Visible;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM