Click here to Skip to main content
Click here to Skip to main content

Building OpenPOS: Part 3 – Scaffolding and Navigation

By , 1 Apr 2010
 

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

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

_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” is 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!

License

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

About the Author

rudigrobler
South Africa South Africa
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 1 Apr 2010
Article Copyright 2010 by rudigrobler
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid