无论我做什么,我的进度条都不会更新。
我的XAML:
<Grid Height="25">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<!--EDITING HERE-->
<Style.Triggers>
<DataTrigger Binding="{Binding Path=PleaseWaitDialog, Mode=OneWay}"
Value="true">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<ProgressBar Value="{Binding Path=Percent}" />
</Grid>
然后在ViewModel中:
private double _percent;
public double Percent
{
get { return _percent; }
set
{
SetProperty("Percent", () => false, () => _percent = value);
}
}
然后我用以下值设置值:
_profileService.ApplyProfile(_data, (s, d) => UpdateApplyProgress(s, d, pleaseWaitVm));
,更新时间为:
private void UpdateApplyProgress(string message, double percent, CUDialogVM dialogVm)
{
//Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, new Action(() => dialogVm.Progress = percent));
dialogVm.Percent = percent;
}
我和调度员一起尝试过,但仍然没有用。我也试过明确地设置值而没有。此外,我已经检查了调试器,并且正在设置viewModel的Percent属性,并且正在触发PropertyChangedEvent。
SetPropertyMethod:
protected bool SetProperty<T>(string propertyName, Func<bool> areEqual, Func<T> setValue)
{
VerifyPropertyName(propertyName);
if (!areEqual.Invoke())
{
setValue.Invoke();
RaisePropertyChanged(propertyName);
IsChanged = true;
}
return true;
}
根据H.B.我现在的约束力是:
<ProgressBar Minimum="0" Maximum="100" Value="{Binding Percent}" />
答案 0 :(得分:1)
ProgressBar.Minimum
和Maximum
默认值为0
和1
,您的值是否在该范围内?如果不相应地更改这些属性。
答案 1 :(得分:0)
在你的XAML中尝试:
<ProgressBar Value="{Binding Path=Percent, UpdateSourceTrigger=PropertyChanged}" />
此外,ProgressBar
值必须介于0和100之间!