我有一个ShellView,它使用带有棱镜的PopupWindowAction的交互对象来显示我的自定义设置视图。我的ShellViewModel包含InteractionRequest对象和一个Delegate Command,它将触发用户交互。用户触发交互后,自定义设置视图(DataFeedManagerView)出现在ShellView的中心。在My DataFeedManagerView中,左侧有一个DataFeeds列表(ListBox控件),右侧是特定于数据Feed的设置视图(具有通过RegionManager设置Region的ContentControl)。首先,我向RegisterViewWithRegion注册了所有视图。然后,我想做的是通过Region的Activate方法在内容控件中激活相关的对象设置视图。当我尝试这样做时,我收到一个错误“找不到区域”。
PS1:也许这是很简单的要求,但是包含许多步骤,因为我的解释有些复杂。我希望代码将更具描述性。
PS2:通过对ContentControl的content属性进行简单绑定,我达到了预期。但是我担心在自定义交互弹出窗口中使用区域时我的错误和/或正确的解决方案是什么。
..::贝壳::..
<Window x:Class="PrismUnityApp.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:views="clr-namespace:PrismUnityApp.Views"
xmlns:constants="clr-namespace:PrismUnityApp.Constants"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
Title="{Binding Title}" Height="480" Width="640">
<DockPanel LastChildFill="True">
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding ConfirmationRequest}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<prism:PopupWindowAction.WindowContent>
<views:DataFeedManagerView/>
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
<Button Content=" Show Data Feed Manager" Command="{Binding ShowDataFeedManagerCommand}"/>
<ContentControl prism:RegionManager.RegionName="{x:Static constants:WellKnownRegionNames.ContentRegion}" />
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
using System.Windows.Input;
using Prism.Commands;
using Prism.Interactivity.InteractionRequest;
using Prism.Mvvm;
namespace PrismUnityApp.ViewModels
{
public class ShellViewModel : BindableBase
{
private string _title = "Prism Unity Application";
public ICommand ShowDataFeedManagerCommand { get; }
public InteractionRequest<IConfirmation> ConfirmationRequest …Run Code Online (Sandbox Code Playgroud) prism ×1