您好我正在尝试将 Telerik Busy 指示器与 MVVM 一起使用。我在主窗口中有忙碌指示器。当窗口中的用户控件之一发生操作(按钮单击)时,用户控件视图模型会向 MinwindowviewModel 发送消息。在消息上,应该显示忙指示符。但这不起作用。为什么这不起作用?
用户控制视图模型
public class GetCustomerVM : ViewModelBase
{
private int _CustomerId;
public int CustomerId
{
get { return _CustomerId; }
set
{
if (value != _CustomerId)
{
_CustomerId = value;
RaisePropertyChanged("CustomerId");
}
}
}
public RelayCommand StartFetching { get; private set; }
public GetCustomerVM()
{
StartFetching = new RelayCommand(OnStart);
}
private void OnStart()
{
Messenger.Default.Send(new Start());
AccountDetails a = AccountRepository.GetAccountDetailsByID(CustomerId);
Messenger.Default.Send(new Complete());
}
}
用户控制视图模型是:
private bool _IsBusy;
public bool IsBusy
{
get { return _IsBusy; }
set
{
if (value != _IsBusy)
{
_IsBusy = value;
RaisePropertyChanged("IsBusy");
}
}
}
public WRunEngineVM()
{
RegisterForMessages();
}
private void RegisterForMessages()
{
Messenger.Default.Register<Start>(this, OnStart);
Messenger.Default.Register<Complete>(this, OnComplete);
}
private void OnComplete(Complete obj)
{
IsBusy = false;
}
private void OnStart(Start obj)
{
IsBusy = true;
}
在主窗口视图中,根元素是
<telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" telerik:StyleManager.Theme="Windows7">