[英]Using ProgressBar with Caliburn.micro
在我的WPF應用程序中,我試圖將控件'ProgressBar'中的屬性'Maximum'與來自ViewModel的屬性綁定(在Caliburn.micro的幫助下)。
查看(xaml):
<ProgressBar x:Name="CurrentProgress"/>
視圖模型:
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}"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.