Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Prism 4 Application Checklist

, 5 Apr 2011
The article provides a step-by-step explanation of how to set up a Prism application.
Prism4Demo.zip
Prism4Demo
Prism4Demo.Common
BaseClasses
bin
Events
obj
Debug
TempPE
Prism4Demo.Common.csproj.user
Properties
Prism4Demo.Library
FsTools
FsTaskButton.dll
Prism
Microsoft.Practices.Prism.dll
Microsoft.Practices.Prism.UnityExtensions.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.dll
Ribbon
RibbonControlsLibrary.dll
Prism4Demo.ModuleA
bin
Commands
obj
Debug
TempPE
Views
Prism4Demo.ModuleA.csproj.user
Properties
Settings.settings
Services
ViewModels
Views
Images
LargeIcon.png
module_a.png
SmallIcon.png
Prism4Demo.ModuleB
bin
Commands
obj
Debug
TempPE
Views
Prism4Demo.ModuleB.csproj.user
Properties
Settings.settings
Services
ViewModels
Views
Images
LargeIcon.png
module_b.png
SmallIcon.png
Prism4Demo
bin
obj
x86
Debug
TempPE
Views
Prism4Demo.csproj.user
Properties
Settings.settings
Services
Utility
ViewModels
Views
Images
LargeIcon.png
new.png
open.png
print.png
ribbon.png
save.png
SmallIcon.png
<ribbon:RibbonWindow x:Class="Prism4Demo.Shell.Views.ShellWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        xmlns:prism="http://www.codeplex.com/prism"
        Title="Prism 4 Demo"
		Width="800" Height="600">

    <!-- Window Resources -->
    <ribbon:RibbonWindow.Resources>
        <LinearGradientBrush x:Key="WindowBackgroundBrush">
            <GradientStop Color="#FFE7E9EB" Offset="0" />
            <GradientStop Color="#FFC6CACF" Offset="1" />
        </LinearGradientBrush>
    </ribbon:RibbonWindow.Resources>

    <ribbon:RibbonWindow.Background>
        <StaticResource ResourceKey="WindowBackgroundBrush" />
    </ribbon:RibbonWindow.Background>

    <!-- Layout Root -->
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition x:Name="RibbonRow" Height="Auto"/>
            <RowDefinition x:Name="ClientRow" Height="*"/>
        </Grid.RowDefinitions>
        
        <!-- Note that the application Ribbon is defined as a Prism region, so that modules can
             load their own tabs into the Ribbon. The Utility folder contains a RibbonRegionAdapter
             class that enables the Ribbon to act as a Prism region. -->

        <!-- Application Ribbon -->
<ribbon:Ribbon x:Name="ApplicationRibbon" 
                Grid.Row="0"  
                Background="Transparent"  
                prism:RegionManager.RegionName="RibbonRegion">
            
            <!-- Ribbon ApplicationMenu (defined here) -->
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu SmallImageSource="Images\ribbon.png">
                    <ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
                                                      x:Name="MenuItem1"
                                                      ImageSource="Images\LargeIcon.png"/>
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>

            <!-- Ribbon QuickAccessToolbar  (defined here) -->
            <ribbon:Ribbon.QuickAccessToolBar>
                <ribbon:RibbonQuickAccessToolBar>
                    <ribbon:RibbonButton Command="{Binding NewCollection}" ToolTip="Create a new file (Ctrl+N)" SmallImageSource="Images\new.png" />
                    <ribbon:RibbonButton Command="{Binding OpenCollection}" ToolTip="Open an existing file (Ctrl+O)" SmallImageSource="Images\open.png" />
                    <ribbon:RibbonButton Command="{Binding SaveCollection}" ToolTip="Save the current file (Ctrl+S)" SmallImageSource="Images\save.png" />
                    <ribbon:RibbonButton Command="{Binding PrintNote}" ToolTip="Print the current file (Ctrl+P)" SmallImageSource="Images\print.png" />
                </ribbon:RibbonQuickAccessToolBar>
            </ribbon:Ribbon.QuickAccessToolBar>

            <!-- Home Tab (defined here) -->
            <ribbon:RibbonTab x:Name="HomeTab"  Header="Home">
                <ribbon:RibbonGroup Header="Group S1">
                    <ribbon:RibbonButton LargeImageSource="Images\LargeIcon.png" Label="Button S1" />
                    <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" Label="Button S2" />
                    <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" Label="Button S3" />
                    <ribbon:RibbonButton SmallImageSource="Images\SmallIcon.png" Label="Button S4" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
        </ribbon:Ribbon> 
        
        <!-- Client Area -->
        <Grid x:Name="ClientArea" Grid.Row="1">

            <!-- Grid Layout -->
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="NavigationColumn" Width="0.200*"/>
                <ColumnDefinition x:Name="WorkspaceColumn" Width="0.600*"/>
            </Grid.ColumnDefinitions>
            <GridSplitter HorizontalAlignment="Left" Width="5" Grid.Column="1"/>

            <!-- Navigation Pane Grid -->
            <Grid x:Name="NavigationPane">

                <!-- Grid Layout -->
                <Grid.RowDefinitions>
                    <RowDefinition x:Name="Navigator" Height="*"/>
                    <RowDefinition x:Name="TaskButtons" Height="Auto"/>
                </Grid.RowDefinitions>

                <!-- Navigator Region -->
                <ContentControl x:Name="NavigatorRegion" Grid.Row="0" prism:RegionManager.RegionName="NavigatorRegion" />

                <!-- Task Button Region -->
                <StackPanel Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,5">
                    <Border Background="{StaticResource WindowBackgroundBrush}" BorderBrush="DarkGray" BorderThickness="1" Height="5" Width="Auto" HorizontalAlignment="Stretch" Margin="5,0,5,5"/>
                    <ItemsControl x:Name="TaskButtonRegion" prism:RegionManager.RegionName="TaskButtonRegion" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
                </StackPanel>

            </Grid>

            <!-- Workspace Region-->
            <ContentControl x:Name="WorkspaceRegion" Grid.Column="1" prism:RegionManager.RegionName="WorkspaceRegion" />

        </Grid>

    </Grid>
</ribbon:RibbonWindow>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

David Veeneman
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 5 Apr 2011
Article Copyright 2011 by David Veeneman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid