I started creating the basic PRISM scaffolding using the PRISM project templates! Based on the prototypes I created, I also defined 2 regions…
<Border Margin="8,2,2,8" Grid.Row="1" BorderBrush="#FF929D31"
BorderThickness="2,2,2,2" CornerRadius="4,4,4,4">
<ContentControl x:Name="NavigationRegion"
prismrgn:RegionManager.RegionName="NavigationRegion"
Style="{StaticResource ContentControlRegionStyle}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"/>
</Border>
<Border Margin="2,2,8,8" Grid.Column="2" Grid.Row="1"
BorderThickness="2,2,2,2" CornerRadius="4,4,4,4"
BorderBrush="#FF929D31" Grid.RowSpan="2">
<ContentControl x:Name="ContentRegion"
prismrgn:RegionManager.RegionName="ContentRegion"
Style="{StaticResource ContentControlRegionStyle}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"/>
</Border>
Next on the list of things that I wanted to do is implement a very basic navigation service. Modules should be able to “register” multiple navigation points that will show up on the navigation pane! Once the user clicks on these navigation points, the module should be able to change the current view. In my first draft, this is how it works...
Modules can “register” new navigation points:
_navigationService.RegisterNavigationPoint(
new NavigationPoint()
{
Name = "Sales",
Category = "Main"
});
Once a navigation point is registered, it will be displayed on the navigation pane. If the user clicks on the navigation point, a “message” gets sent using the event aggregator. Subscribing to these messages is extremely easy:
_eventAggregator.GetEvent<NavigateEvent>().Subscribe(Navigate, true);
Every time one of these “messages” are raised, the following event handle fires:
public void Navigate(NavigationPoint point)
{
var contentRegion = _regionManager.Regions["ContentRegion"];
if (point.Name == "Sales" && point.Category == "Main")
{
var view = _container.Resolve<SalesView_Main>();
contentRegion.Add(view);
contentRegion.Activate(view);
}
if (point.Name == "Sales" && point.Category == "Administration")
{
var view = _container.Resolve<SalesView_Administrator>();
contentRegion.Add(view);
contentRegion.Activate(view);
}
}
And that is it, now a module can register navigation points on the navigation pane!
As part of the scaffolding, I also created 3 extra modules (Sales, Customers and Stock).
In the next part, we will start implementing some of the main features of OpenPOS!
CodeProject