的Caliburn.micro使用ProgressBar
作者:互联网
在我的WPF应用程序中,我试图将控件“ ProgressBar”的“ Maximum”属性与ViewModel的属性(在Caliburn.micro的帮助下)绑定在一起.
查看(xaml):
<ProgressBar x:Name="CurrentProgress"/>
ViewModel:
private int currentProgress;
public int CurrentProgress
{
get { return currentProgress; }
set
{
if (currentProgress == value)
{
return;
}
currentProgress = value;
NotifyOfPropertyChange(() => CurrentProgress);
}
}
问题: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}"/>
您的x:Name =“ CurrentProgress”会转换为Value =“ {Binding Path = CurrentProgress,Mode = TwoWay}”,所以类似的事情也应该起作用:
<ProgressBar Value="{Binding Path=CurrentProgress}" Maximum="{Binding Path=MaximumProgress}"/>
标签:progress-bar,wpf,c,caliburn-micro 来源: https://codeday.me/bug/20191030/1967061.html