绑定进度条可见性mvvm无法正常工作

时间:2014-07-15 03:35:39

标签: c# wpf xaml mvvm mvvm-light

抱歉我的英语不好:x

我在我的项目中使用MVVM Light工具包,我尝试折叠并恢复了一个进度条,但我已经使用了大量的代码片段并浏览了很多围绕这个主题的论坛,我无法解决我的问题。

我的Home.xaml

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

我的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();
    }

当我在我的Home.xaml.cs中使用我的更新方法它的工作(不绑定 - &gt;(progressbar.Visibility = Visibility.Visible))但当我尝试通过绑定在我的VM它没有工作:[

你能帮我吗?

最诚挚的问候;)

1 个答案:

答案 0 :(得分:2)

您正在更改字段,更新更新方法中的属性

      this.ProgressBarVisibility = Visibility.Visible;