Regions in ChildWindows + Prims 4 + MVVM + Silverlight

Topics: Prism v4 - Silverlight 4
Dec 21, 2011 at 9:45 PM

Hi I have the following problem, I have a region in a ChildWindows, I call the ChildWindowsin the traditional way "CW.Show ()" command and fill the Region with a view of one of mymodules, the first time this Charging. . works perfect, close the ChildEindows and rebuildgives me to UpdateRegionsExeptions is this? Remove and try to make a closing event inthe ChildWindows and nothing. I could help .. Here my code:

Code that calls the ChildWindows::

        private void NavigateToView(string id)
        {
            WindowsView w = new WindowsView();
            w.Show();

            UriQuery parameters = new UriQuery();
            parameters.Add("ID", id);
            _regionManager.RequestNavigate(RegionNames.PopupTestRegion,
                                            new Uri("EditView" + parameters.ToString(), UriKind.Relative),
                                            NavigationCompleted);
        }

Code of ChilWindows::

        IRegionManager regionManager;
        public WindowsView()
        {
            regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
            this.SetValue(RegionManager.RegionManagerProperty, regionManager);
            InitializeComponent();
            this.Closed += new EventHandler(WindowsView_Closed);
        }
 
        void WindowsView_Closed(object sender, EventArgs e)
        {
            regionManager.Regions["PopupTestRegion"].RemoveAll();
           
        }

XAML ChildWindows 

<controls:ChildWindow x:Class="Module1.Views.WindowsView"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                      xmlns:prism="http://www.codeplex.com/prism"
           Width="723" Height="300" 
           Title="WindowsView"          >
    <Grid x:Name="LayoutRoot" Margin="2">
        <ContentControl prism:RegionManager.RegionName="PopupTestRegion" 
                       VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />
    </Grid>
</controls:ChildWindow>

 


Developer
Dec 22, 2011 at 7:23 PM
Edited Dec 22, 2011 at 7:25 PM

Hi,

We tried to reproduce the exception you mentioned without success. You can find the sample I created based on my understanding of your scenario in the my Skydrive account under the name "RegionInChildWindowWithNavigation.zip".

If you still can't find a solution to your problem, it would be helpful if you could provide us with a repro sample application that portrays it, so that we can help you further with this.

Thanks,

Agustin Adami
http://blogs.southworks.net/aadami