Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on my understanding, <strong>Prism</strong> loads and show by default the first <strong>View</strong> that gets registered on each <strong>Region</strong> (Only the first <strong>View</strong> would be shown if the region is set on a <strong>ContentControl</strong> item).</p> <p>Therefore, you could <em>deactivate</em> the undesired <strong>Views</strong> on each <strong>RegionBehavior</strong> you don't want to show at startUp. This would make that when the desired <strong><em>StartUp View</em></strong> is added, it would get <em>activated</em> as there is no other <em>active</em> <strong>View</strong> yet. </p> <p>Another alternative would be to register each <strong>View</strong> on the corresponding <strong>Module</strong> <em>initialize()</em> method, instead of using <strong>RegionBehaviours</strong>. So finally, after adding each <strong>View</strong> to the corresponding <strong>Region</strong>, you would decide to <em>deactivate</em> the <strong>View</strong> whether it is the <strong><em>StartUp View</em></strong> or not.</p> <p><strong>UPDATE:</strong></p> <p>The following implementation shows a possible alternative for <strong><em>deactivating</em></strong> non-startup <strong>Views</strong> on each <strong>RegionBehavior</strong>. In order to get a more elegant solution, you could create a dictionary or a simple static class that would return the <strong>StartUpView</strong> name for the corresponding <strong>Region</strong>, and then call it as shown below:</p> <pre><code>private void AddRegisteredViews() { ... var view = viewEntry.Value; if (!Region.Views.Contains(view)) { Region.Add(view); if (view.GetType().Name != StartUpViewNames.getViewNameFromRegion(Region)) { Region.deactivate(view); } } ... } </code></pre> <p>Notice that I after the <strong>StartUpView</strong> is found and it is kept <em>active</em>, it continues deactivating the following added <strong>views</strong>, but you could leave them <em>active</em>. As I mentioned, the <strong>View</strong> that would be shown, would be the first one which gets <em>Active</em> in the <strong>Region</strong>.</p> <p>I hope this helps, Regards.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks for the response. Can you just clarify, how would I deactivate the view on the region behaviour? I got around this problem by removing the custom attribute I added for automatic discovery for the unwanted views and so I only get the one with the [ViewExport] attribute on it displayed at startup, however when I navigate, it still finds the other views. How are they available to be found if I haven't given them a [ViewExport] attribute and added them to that region? Are they being added elsewhere?
      singulars
    2. COTo confirm, I only have an [Export] attribute on the other view, no mention of which region I want it added to, so I can't see anywhere where I am specifying which region to put it in, only when I do the regionmanager.RequestNavigate("regionname", "viewname") is the only place I can see where this view is tied to the region, but yet it still works and displays correctly which confuses me, as if I don't need the [ViewExport(RegIonName="RegionName"] attribute, why am I even doing it? Without that attribute, the auto discovery code I pasted surely isn't picking up this view?
      singulars
    3. COThe [Export] attribute makes the **View** be registered into the **MEF** container. When you navigate to the target **View** for the first time, this is not yet registered into the **Region**. However, _RequestNavigate()_ method looks for the **View** into the **MEF** container if it was not found on the **Region's Views** collection. Therefore, as the **View** was registered in the container, the **View** is added to the **Region** and the Navigation is performed afterwards.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload