View removal / deactivation in WPF + PRISM not working -



View removal / deactivation in WPF + PRISM not working -

i have shell (window) contentcontrol item

<contentcontrol regions:regionmanager.regionname="maincontentregion"/>

i have 2 views register unity in separate projects such

regionmanager.registerviewwithregion("maincontentregion", () => new musicgeneration());

and

regionmanager.registerviewwithregion("maincontentregion", () => new startupcontrol(container));

at application start-up startupcontrol displayed in part required. however, trying startupcontrol replaced musicgenerator proving fruitless en-devour.

at first tried changing view such (since contentcontrol hosts 1 view @ time')

regionmanager.regions["maincontentregion"].activate(container.resolve<musicgeneration>());

but cuases error.

the next attempt

regionmanager.regions["maincontentregion"].add(container.resolve<musicgeneration>());

truly adds view list of regions managed manager, still never removes original (startupcontrol) view.

i have tried well

regionmanager.requestnavigate("maincontentregion", new uri("musicgeneration", urikind.relative));

the original view i.e startupcontrol never removed rootvisual.

complete code listing 2 views

startupcontrol.xaml.cs

public partial class startupcontrol : iregionmemberlifetime { public bool keepalive { { homecoming false; } } public startupcontrol(iunitycontainer container) { initializecomponent(); datacontext = container.resolve<startupviewmodel>(); } }

startupcontrol.xaml

<usercontrol x:class="startupmodule.views.startupcontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" > <grid name="container"> has content here displays correctly </grid> </usercontrol>

musicgenerator.xaml.cs

using microsoft.practices.prism.regions; namespace geneticmusic.views { /// <summary> /// interaction logic startupcontrol.xaml /// </summary> public partial class musicgeneration : iregionmemberlifetime { public bool keepalive { { homecoming false; } } public musicgeneration() { initializecomponent(); } } }

generatemusic.xaml

<usercontrol x:class="geneticmusic.views.musicgeneration" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit" mc:ignorable="d" > <grid name="container"> content here... displays correctly </grid> </usercontrol>

edit: seems duplicate

prism requestnavigate not work

wpf view prism regions cal

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -