Frage

I have been learning about the Composite Applicaation Library, and came across a question: is it possible to build multi page applications using CAL?

All the examples I have seen use a single page with regions defined.

Can something like multiple shells be used? - If so is against CAL methodolgies to do so?

Moreover is it ok to build multi page apps using CAL or is it sinle page app exclusively?

Also it multiple shells or perhaps multiple Bootstrappers is possible a sample showing the correct way to do it is appreciated.

Thanks

War es hilfreich?

Lösung

Prism can be used for multi-page applications.

One way is described by the Prism developer guide. Quickstarts are also provided to help the developer.

However I find this way quite heavy to implement. And when confronted to the issue of multi-paging with Prism, I usually prefer a simpler solution :

  • First, in the Shell, I define regions within ContentControls within a single Grid, so that these ContentControls will be "on the same page". The grid defines the bounds of the page, and you can put extend it to the whole window if you want to.
  • Then, I have a NavigationManager instance that will be responsible for loading the DataContext of each ContentControl/Region of the Shell at the right time. At each time, a single ContentControl has a DataContext filled, and all the other's are null.
  • Finally, I inject, at Module Initialization time in each region the view that will fill it, thanks to RegisterViewWithRegion. An important thing to do is this.

    <UserControl>
        <UserControl.Resources>
            <DataTemplate DataType="{x:Type my:ViewModel}">
                ...
            </DataTemplate>
        </UserControl.Resources>
        <ContentControl Content="{Binding }" />
    </UserControl>
    

Like this, your view will not appear if the DataContext is null, thus navigation. In order to call the navigation methods, you can use globally available commands as described in the developer guide. This allows you to bind your navigation button commands directly to the navigation command from any module.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top