如何在prism mef wpf的另一个区域中弹出子窗口时禁用该区域
我在Shell中有两个区域-工具栏区域和内容区域。如何在prism mef wpf的另一个区域中弹出子窗口时禁用该区域,wpf,prism,mef,Wpf,Prism,Mef,我在Shell中有两个区域-工具栏区域和内容区域。 内容区域有许多视图-父窗口和子窗口。当子窗口弹出时,工具栏区域未被禁用。应如何禁用工具栏区域?您可以将viewModel的主要内容属性IsEnabled绑定到布尔属性ispoupgone。在工具栏的构造函数中,将EventAggregator订阅到事件PopupUphinowStateChanged,并将负载作为布尔值。然后,当弹出窗口显示时,将此事件发布为True,关闭时发布为False private bool isPopupGone =
内容区域有许多视图-父窗口和子窗口。当子窗口弹出时,工具栏区域未被禁用。应如何禁用工具栏区域?您可以将viewModel的主要内容属性
IsEnabled
绑定到布尔属性ispoupgone
。在工具栏的构造函数中,将EventAggregator订阅到事件PopupUphinowStateChanged
,并将负载作为布尔值。然后,当弹出窗口显示时,将此事件发布为True,关闭时发布为False
private bool isPopupGone = true; // default/original state assumed to be no childs showing
public bool IsPopupGone
{
get { return isPopupGone; }
set { isPopupGone = value; /* implement notifypropertychanged */ }
}
public ToolbarViewModel(IEventAggregator eventAggregator)
{
EventAggregator = eventAggregator;
EventAggregator.GetEvent<PopupWindowStateChanged>().Subscribe(UpdateEnabledState);
}
public void UpdateEnabledState(bool isPopupShowing)
{
IsPopupGone = !isPopupShowing;
}
<UserControl x:Class="ToolbarView">
<Menu IsEnabled="{Binding Path=IsPopupShown, Mode=OneWay}">
...
</Menu>
</UserControl>
private bool isPopupGone=true;//默认/原始状态假定为无子项显示
公共广播网
{
获取{return isPopupGone;}
设置{ispoupgone=value;/*实现notifypropertychanged*/}
}
公共工具栏视图模型(IEventAggregator事件聚合器)
{
EventAggregator=EventAggregator;
EventAggregator.GetEvent().Subscribe(UpdateEnabledState);
}
public void UpdateEnabledState(bool-isPopupShowing)
{
ISPopupOne=!isPopupShowing;
}
...
当创建/显示(true)或关闭(false)时,弹出窗口只需在适当的时候执行以下操作
EventAggregator.GetEvent().Publish(true);//假的
我不喜欢属性IsPopupGone的命名,我宁愿使用IsPopupShowing并在XAML中使用转换器,但这对于您/其他人来说可能更容易回答
EventAggregator.GetEvent<PopupShowingChanged>().Publish(true); // false