C# 将ProgressBar与Caliburn.micro一起使用

C# 将ProgressBar与Caliburn.micro一起使用,c#,wpf,progress-bar,caliburn.micro,C#,Wpf,Progress Bar,Caliburn.micro,在我的WPF应用程序中,我试图将控件“ProgressBar”中的属性“Maximum”与ViewModel中的属性绑定(借助Caliburn.micro) 视图(xaml): 问题是:Caliburn.micro是否也可以绑定最大值。我尝试创建一个属性,如: private int maximumProgress; public int MaximumProgress { get { return maximumProgress; } set { if (maximumPr

在我的WPF应用程序中,我试图将控件“ProgressBar”中的属性“Maximum”与ViewModel中的属性绑定(借助Caliburn.micro)

视图(xaml):

问题是:Caliburn.micro是否也可以绑定最大值。我尝试创建一个属性,如:

private int maximumProgress;
public int MaximumProgress
{
  get { return maximumProgress; }
  set
  {
    if (maximumProgress == value)
    {
      return;
    }

    maximumProgress = value;
    NotifyOfPropertyChange(() => MaximumProgress);
  }
}
但这是行不通的。 我还在Caliburn文档中搜索,但在那里找不到帮助


感谢您的帮助

您可以像其他
DependencyProperty一样绑定
ProgressBar.Maximum
。这应该起作用:

<ProgressBar x:Name="CurrentProgress" Maximum="{Binding Path=MaximumProgress}"/>

谢谢你的回答。对,你的答案是正确的。但我认为“caliburn”允许它约束这个属性而不是约定。我不这么认为。据我所知,Caliburn.Micro不支持每个
框架元素超过一个约定
应该有一种方法来设置它,ItemsControl同时绑定SelectedItem和ItemSource。我希望其他人做了这项艰苦的工作,但我想我必须自己做。。。。
private int maximumProgress;
public int MaximumProgress
{
  get { return maximumProgress; }
  set
  {
    if (maximumProgress == value)
    {
      return;
    }

    maximumProgress = value;
    NotifyOfPropertyChange(() => MaximumProgress);
  }
}
<ProgressBar x:Name="CurrentProgress" Maximum="{Binding Path=MaximumProgress}"/>
<ProgressBar Value="{Binding Path=CurrentProgress}" Maximum="{Binding Path=MaximumProgress}"/>