【发布时间】:2017-10-27 20:49:12
【问题描述】:
这里是初学者 - 我正在努力解决访问视图模型属性的问题。在我的特殊情况下,我有一个包含两个不同项目的解决方案。一个包含 UI 组件,另一个包含大部分“工作”。
我的 UI 项目中的视图模型包含以下属性:
private int _createfileprogress { get; set; }
public int CreateFileProgress
{
get { return _createfileprogress ; }
set
{
if (value == _createfileprogress )
return;
_createfileprogress = value;
OnPropertyChanged("CreateFileProgress");
}
}
这个int属性的作用是填充一个进度条的进度。我想在我的另一个项目中引用它,其中执行了一个长时间运行的方法:
public void LongRunningMethod()
{
CreateFileProgress= 0;
// Do some calculations
CreateFileProgress= 10
// More calculations and external calls
CreateFileProgress= 20
// etc.
}
但我找不到连接这两者的正确方法。我确定这样做是错误的 - 将不胜感激任何指导。谢谢!
【问题讨论】:
-
stackoverflow.com/questions/46156390/…看看这个答案,我做了一个支持绑定的进度条窗口