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

Tagged as

Go to top

Building OpenPOS: Part 3 – Scaffolding and Navigation

, 9 Sep 2010
Rate this:
Please Sign up or sign in to vote.
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…

<!--<span class="code-comment"> Navigation Region --></span>
<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>

<!--<span class="code-comment"> Content Region --></span>
<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!

License

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

Share

About the Author

rudigrobler

South Africa South Africa
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 9 Sep 2010
Article Copyright 2010 by rudigrobler
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid