Click here to Skip to main content
15,884,298 members
Articles / Desktop Programming / XAML

A Sample Silverlight 4 Application Using MEF, MVVM, and WCF RIA Services - Part 1

Rate me:
Please Sign up or sign in to vote.
4.84/5 (108 votes)
7 Jul 2011CPOL9 min read 2.1M   30.9K   298  
Part 1 of a series describing the creation of a Silverlight business application using MEF, MVVM Light, and WCF RIA Services.
<UserControl x:Class="IssueVision.Client.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:system="clr-namespace:System;assembly=mscorlib" 
    xmlns:local="clr-namespace:IssueVision.Client;assembly=IssueVision.Client"
    xmlns:common="clr-namespace:IssueVision.Common;assembly=IssueVision.Common"
    xmlns:menu="clr-namespace:System.Windows.Controls;assembly=MenuControls"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    
    <UserControl.Resources>
        <common:NotOperatorValueConverter x:Key="notOperatorValueConverter"/>
        <common:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
    </UserControl.Resources>

    <toolkit:BusyIndicator Style="{StaticResource BusyIndicatorStyle}" IsBusy="{Binding Path=IsBusy}">
        <common:MainPageControl x:Name="mainPageControl" IsLoggedIn="{Binding Path=IsLoggedIn}">
            <common:MainPageControl.TitleContent>
                <toolkit:DockPanel Style="{StaticResource MainPageTitleStyle}">
                    <TextBlock Text="ISSUEVISION" Style="{StaticResource MainPageTitleTextOneStyle}"/>
                    <TextBlock Text="for Silverlight" Style="{StaticResource MainPageTitleTextTwoStyle}"/>
                    <StackPanel Visibility="{Binding Path=IsLoggedIn, 
                                             Mode=OneWay, 
                                             Converter={StaticResource booleanToVisibilityConverter}}"
                                Style="{StaticResource LogoutPanelStyle}">
                        <TextBlock Text="{Binding Path=WelcomeText}"
                                   Style="{StaticResource WelcomeTextStyle}"/>
                        <TextBlock Text="|" Style="{StaticResource SpacerStyle}"/>
                        <TextBlock Text="{Binding Path=CurrentScreenText}"
                                   Style="{StaticResource CurrentScreenTextStyle}"/>
                        <TextBlock Text="|" Style="{StaticResource SpacerStyle}"/>
                        <HyperlinkButton x:Name="hyperlinkButton_Logout" Content="logout" 
                                         Style="{StaticResource LogoutButtonStyle}"
                                         Command="{Binding Path=LogoutCommand}"
                                         IsEnabled="{Binding Path=IsLoggedOut,
                                                     Mode=OneWay, 
                                                     Converter={StaticResource notOperatorValueConverter}}">
                            <HyperlinkButton.CommandParameter>
                                <system:Boolean>false</system:Boolean>
                            </HyperlinkButton.CommandParameter>
                        </HyperlinkButton>
                    </StackPanel>
                </toolkit:DockPanel>
            </common:MainPageControl.TitleContent>
            <common:MainPageControl.LoggedInMenuContent>
                <menu:Menu Style="{StaticResource LoggedInMenuStyle}">
                    <menu:MenuItem Header="Home"
                                   Command="{Binding Path=ChangeScreenCommand}"
                                   CommandParameter="Home"/>
                    <menu:MenuItem Header="Issues">
                        <menu:MenuItem Header="New Issue"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="New Issue"/>
                        <menu:MenuItem Header="My Issues"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="My Issues"/>
                        <menu:MenuItem Header="All Issues"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="All Issues"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Reports">
                        <menu:MenuItem Header="Bug Report"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="Bug Report"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Admin">
                        <menu:MenuItem Header="My Profile"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="My Profile"/>
                        <menu:MenuItem Header="User Maintenance"
                                       Visibility="{Binding Path=IsAdmin, 
                                                    Mode=OneWay, 
                                                    Converter={StaticResource booleanToVisibilityConverter}}"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="User Maintenance"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Themes">
                        <menu:MenuItem Header="Bureau Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="BureauBlue.xaml"
                                       IsChecked="{Binding IsBureauBlueTheme}"/>
                        <menu:MenuItem Header="Expression Light"                                           
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ExpressionLight.xaml"
                                       IsChecked="{Binding IsExpressionLightTheme}"/>
                        <menu:MenuItem Header="Shiny Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ShinyBlue.xaml"
                                       IsChecked="{Binding IsShinyBlueTheme}"/>
                        <menu:MenuItem Header="Twilight Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="TwilightBlue.xaml"
                                       IsChecked="{Binding IsTwilightBlueTheme}"/>
                    </menu:MenuItem>
                </menu:Menu>
            </common:MainPageControl.LoggedInMenuContent>
            <common:MainPageControl.LoggedOutMenuContent>
                <menu:Menu Style="{StaticResource LoggedOutMenuStyle}">
                    <menu:MenuItem Header="Themes">
                        <menu:MenuItem Header="Bureau Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="BureauBlue.xaml"
                                       IsChecked="{Binding IsBureauBlueTheme}"/>
                        <menu:MenuItem Header="Expression Light"                                           
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ExpressionLight.xaml"
                                       IsChecked="{Binding IsExpressionLightTheme}"/>
                        <menu:MenuItem Header="Shiny Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ShinyBlue.xaml"
                                       IsChecked="{Binding IsShinyBlueTheme}"/>
                        <menu:MenuItem Header="Twilight Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="TwilightBlue.xaml"
                                       IsChecked="{Binding IsTwilightBlueTheme}"/>
                    </menu:MenuItem>
                </menu:Menu>
            </common:MainPageControl.LoggedOutMenuContent>
            <common:MainPageControl.LoginPageContent>
                <Grid Style="{StaticResource MainLoginPageStyle}">
                    <local:LoginForm HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>
            </common:MainPageControl.LoginPageContent>
            <common:MainPageControl.MainPageContent>
                <ContentControl x:Name="mainPageContent" Style="{StaticResource MainPageContentStyle}">
                    <local:Home/>
                </ContentControl>
            </common:MainPageControl.MainPageContent>
        </common:MainPageControl>
    </toolkit:BusyIndicator>
    
</UserControl>

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)


Written By
Software Developer (Senior)
United States United States
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET

Comments and Discussions