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

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

, 7 Jul 2011 CPOL
Part 1 of a series describing the creation of a Silverlight business application using MEF, MVVM Light, and WCF RIA Services.
IssueVisionforSilverlightSetup20110630.zip
IssueVision for Silverlight Setup
IssueVisionSetup.msi
setup.exe
IssueVision_for_Silverlight_setup.zip
IssueVisionSetup.msi
setup.exe
IssueVision_Silverlight20110630.zip
IssueVision.Silverlight
Assemblies
GalaSoft.MvvmLight.Extras.SL4.dll
GalaSoft.MvvmLight.SL4.dll
MenuControls.dll
System.Windows.Controls.DataVisualization.Toolkit.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
Database
IssueVision.Client
IssueVision.Client.csproj.user
Assets
Signin.png
Controls
Properties
Views
IssueVision.Common
IssueVision.Common.csproj.user
Controls
Helpers
Models
Properties
Resources
Themes
IssueVision.Data
IssueVision.Data.csproj.user
Properties
Web
Resources
IssueVision.Data.Web
IssueVision.edmx
Helpers
MetadataClasses
Properties
Resources
Services
IssueVision.Model
IssueVision.Model.csproj.user
Properties
IssueVision.Setup
IssueVisionSetup.vdproj
IssueVision.ViewModel
IssueVision.ViewModel.csproj.user
Properties
IssueVision.Web
IssueVision.Web.csproj.user
Properties
IssueVision_Silverlight_20110316.zip
GalaSoft.MvvmLight.Extras.SL4.dll
GalaSoft.MvvmLight.SL4.dll
MenuControls.dll
System.Windows.Controls.DataVisualization.Toolkit.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
IssueVision.Client.csproj.user
Signin.png
DataSources
IssueVision.Data.Web.IssueVisionContext.datasource
IssueVision.Data.Web.PasswordResetContext.datasource
IssueVision.Common.csproj.user
IssueVision.Data.csproj.user
IssueVision.edmx
DataTypes
IssueVision.Model.csproj.user
IssueVisionSetup.vdproj
IssueVision.ViewModel.csproj.user
IssueVision.Web.csproj.user
IssueVision_Silverlight_20110606.zip
GalaSoft.MvvmLight.Extras.SL4.dll
GalaSoft.MvvmLight.SL4.dll
MenuControls.dll
System.Windows.Controls.DataVisualization.Toolkit.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
IssueVision.Client.csproj.user
Signin.png
IssueVision.Common.csproj.user
IssueVision.Data.csproj.user
IssueVision.edmx
IssueVision.Model.csproj.user
IssueVisionSetup.vdproj
IssueVision.ViewModel.csproj.user
IssueVision.Web.csproj.user
IssueVision_Silverlight_Setup.zip
IssueVisionSetup.msi
setup.exe
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:local="clr-namespace:IssueVision.Common;assembly=IssueVision.Common">

    <Style TargetType="local:FlipControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:FlipControl">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition To="Normal" From="Flipped" GeneratedDuration="0:0:1">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="BackContentProjection"
                                                             Storyboard.TargetProperty="RotationY" To="-90" Duration="0:0:0.5"/>
                                            <DoubleAnimation Storyboard.TargetName="FrontContentProjection" 
                                                             BeginTime="0:0:0.5" Storyboard.TargetProperty="RotationY" To="0" Duration="0:0:0.5"/>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition To="Flipped" From="Normal" GeneratedDuration="0:0:1">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="FrontContentProjection"
                                                             Storyboard.TargetProperty="RotationY" To="90" Duration="0:0:0.5"/>
                                            <DoubleAnimation Storyboard.TargetName="BackContentProjection"
                                                             BeginTime="0:0:0.5" Storyboard.TargetProperty="RotationY" To="0" Duration="0:0:0.5"/>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackContentProjection"
                                                         Storyboard.TargetProperty="RotationY" To="-90" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Flipped">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FrontContentProjection"
                                                         Storyboard.TargetProperty="RotationY" To="90" Duration="0:0:0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>

                        <!-- This is the front content. -->
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Background="{TemplateBinding Background}">
                            <ContentPresenter Content="{TemplateBinding FrontContent}"/>
                            <Border.Projection>
                                <PlaneProjection x:Name="FrontContentProjection"></PlaneProjection>
                            </Border.Projection>
                        </Border>

                        <!-- This is the back content. -->
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Background="{TemplateBinding Background}">
                            <ContentPresenter Content="{TemplateBinding BackContent}"/>
                            <Border.Projection>
                                <PlaneProjection x:Name="BackContentProjection"></PlaneProjection>
                            </Border.Projection>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MainPageControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MainPageControl">
                    <toolkit:DockPanel LastChildFill="True">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition To="LoggedIn" From="LoggedOut" GeneratedDuration="0:0:1.2">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="visibleStop"
                                                             Storyboard.TargetProperty="Offset" To="1.2" Duration="0:0:1.2"/>
                                            <DoubleAnimation Storyboard.TargetName="transparentStop" 
                                                             Storyboard.TargetProperty="Offset" To="1" BeginTime="0:0:0.2" Duration="0:0:1"/>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition To="LoggedOut" From="LoggedIn" GeneratedDuration="0:0:1.2">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="visibleStop"
                                                             Storyboard.TargetProperty="Offset" To="0" Duration="0:0:1.2"/>
                                            <DoubleAnimation Storyboard.TargetName="transparentStop"
                                                             Storyboard.TargetProperty="Offset" To="0" BeginTime="0:0:0.2" Duration="0:0:1"/>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="LoggedIn">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="visibleStop"
                                                             Storyboard.TargetProperty="Offset" To="1.2" Duration="0:0:0"/>
                                        <DoubleAnimation Storyboard.TargetName="transparentStop" 
                                                             Storyboard.TargetProperty="Offset" To="1" Duration="0:0:0"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoginPageBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainPageBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoggedOutMenuBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoggedInMenuBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="LoggedOut">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="visibleStop"
                                                             Storyboard.TargetProperty="Offset" To="0" Duration="0:0:0"/>
                                        <DoubleAnimation Storyboard.TargetName="transparentStop" 
                                                             Storyboard.TargetProperty="Offset" To="0" Duration="0:0:0"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoginPageBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainPageBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoggedOutMenuBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoggedInMenuBorder"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid toolkit:DockPanel.Dock="Top">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="42"/>
                                <RowDefinition Height="21"/>
                            </Grid.RowDefinitions>
                            <!-- This is the title content. -->
                            <Border Grid.Row="0">
                                <ContentPresenter Content="{TemplateBinding TitleContent}"/>
                            </Border>

                            <!-- This is the loggedIn menu content. -->
                            <Border x:Name="LoggedInMenuBorder" Grid.Row="1" Visibility="Collapsed">
                                <ContentPresenter Content="{TemplateBinding LoggedInMenuContent}"/>
                            </Border>

                            <!-- This is the loggedOut menu content. -->
                            <Border x:Name="LoggedOutMenuBorder" Grid.Row="1" Visibility="Visible">
                                <ContentPresenter Content="{TemplateBinding LoggedOutMenuContent}"/>
                            </Border>
                        </Grid>
                        <Grid>
                            <!-- This is the main page content. -->
                            <Border x:Name="MainPageBorder" Grid.Row="0"                                   
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="{TemplateBinding CornerRadius}"
                                    Background="{TemplateBinding Background}">
                                <ContentPresenter Content="{TemplateBinding MainPageContent}"/>
                            </Border>

                            <!-- This is the login page content. -->
                            <Border x:Name="LoginPageBorder" Grid.Row="0">
                                <ContentPresenter Content="{TemplateBinding LoginPageContent}"/>
                                <Border.OpacityMask>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                        <GradientStop Offset="0" Color="Transparent" x:Name="transparentStop"/>
                                        <GradientStop Offset="0" Color="Black" x:Name="visibleStop"/>
                                    </LinearGradientBrush>
                                </Border.OpacityMask>
                            </Border>
                        </Grid>
                    </toolkit:DockPanel>               
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

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

Weidong Shen
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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411022.1 | Last Updated 7 Jul 2011
Article Copyright 2010 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid