Click here to Skip to main content
15,883,705 members
Articles / Programming Languages / XML

Building OpenPOS: Part 3 – Scaffolding and Navigation

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
9 Sep 2010CPOL1 min read 9.5K   1  
Scaffolding and Navigation

I started creating the basic PRISM scaffolding using the PRISM project templates! Based on the prototypes I created, I also defined 2 regions…

XML
<!-- Navigation Region -->
<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>

<!-- Content Region -->
<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:

C#
_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:

C#
_eventAggregator.GetEvent<NavigateEvent>().Subscribe(Navigate, true);

Every time one of these “messages” are raised, the following event handle fires:

C#
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!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --