Click here to Skip to main content
15,894,825 members
Articles / Desktop Programming / WPF

Building WPF Applications with Self-Tracking Entity Generator and Visual Studio 2012 - Project Setup

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
17 Mar 2013CPOL8 min read 69.2K   3.5K   44  
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator and Visual Studio 2012.
<extToolkit:ChildWindow x:Class="SchoolSample.CoursePageFilter"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
                        xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
                        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                        xmlns:local="clr-namespace:SchoolSample"
                        Caption="{Binding Path=Strings.Filter,
                                          Source={StaticResource ApplicationResources}}"
                        Style="{StaticResource ChildWindowStyle}"
                        local:DialogResultBehavior.DialogResult="{Binding DialogResult}">
    <Grid x:Name="LayoutRoot"
          Width="Auto"
          Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <!--  Course Name  -->
        <TextBlock Grid.Row="0"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.CourseName,
                                  Source={StaticResource ApplicationResources}}" />
        <TextBox Grid.Row="0"
                 Grid.Column="1"
                 Margin="10"
                 VerticalAlignment="Center"
                 Text="{Binding CourseName,
                                Mode=TwoWay}" />
        <ComboBox Grid.Row="0"
                  Grid.Column="2"
                  Width="100"
                  Margin="10"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=ListSortDirectionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=CourseNameSortDirectionIndex,
                                          Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding Path=CourseNameSortDirectionSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <TextBlock Grid.Row="0"
                   Grid.Column="3"
                   Width="10"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=CourseNameSortOrder,
                                  Mode=OneWay}" />
        <!--  Joint Condition 1  -->
        <TextBlock Grid.Row="1"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.JointCondition,
                                  Source={StaticResource ApplicationResources}}" />
        <ComboBox Grid.Row="1"
                  Grid.Column="1"
                  Width="70"
                  Margin="10"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=JointConditionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=JointCondition1Index,
                                          Mode=TwoWay}" />
        <!--  Instructor Name  -->
        <TextBlock Grid.Row="2"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.InstructorName,
                                  Source={StaticResource ApplicationResources}}" />
        <TextBox Grid.Row="2"
                 Grid.Column="1"
                 Width="200"
                 Margin="10"
                 VerticalAlignment="Center"
                 Text="{Binding InstructorName,
                                Mode=TwoWay}" />
        <ComboBox Grid.Row="2"
                  Grid.Column="2"
                  Width="100"
                  Margin="10"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=ListSortDirectionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=InstructorNameSortDirectionIndex,
                                          Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding Path=InstructorNameSortDirectionSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <TextBlock Grid.Row="2"
                   Grid.Column="3"
                   Width="10"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=InstructorNameSortOrder,
                                  Mode=OneWay}" />
        <!--  Joint Condition 2  -->
        <TextBlock Grid.Row="3"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.JointCondition,
                                  Source={StaticResource ApplicationResources}}" />
        <ComboBox Grid.Row="3"
                  Grid.Column="1"
                  Width="70"
                  Margin="10"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=JointConditionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=JointCondition2Index,
                                          Mode=TwoWay}" />
        <!--  Course Start Date  -->
        <TextBlock Grid.Row="4"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.CourseStartDateField,
                                  Source={StaticResource ApplicationResources}}" />
        <StackPanel Grid.Row="4"
                    Grid.Column="1"
                    Orientation="Horizontal">
            <ComboBox Width="50"
                      Margin="10,10,0,10"
                      HorizontalAlignment="Left"
                      VerticalAlignment="Center"
                      ItemsSource="{Binding Path=CompareOperator,
                                            Mode=OneWay}"
                      SelectedIndex="{Binding Path=CourseStartDateCompareOperatorIndex,
                                              Mode=TwoWay}" />
            <DatePicker Width="140"
                        Margin="10"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        SelectedDate="{Binding Path=CourseStartDate,
                                               Mode=TwoWay}" />
        </StackPanel>
        <ComboBox Grid.Row="4"
                  Grid.Column="2"
                  Width="100"
                  Margin="10"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=ListSortDirectionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=CourseStartDateSortDirectionIndex,
                                          Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding Path=CourseStartDateSortDirectionSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <TextBlock Grid.Row="4"
                   Grid.Column="3"
                   Width="10"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=CourseStartDateSortOrder,
                                  Mode=OneWay}" />
        <!--  Joint Condition 3  -->
        <TextBlock Grid.Row="5"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.JointCondition,
                                  Source={StaticResource ApplicationResources}}" />
        <ComboBox Grid.Row="5"
                  Grid.Column="1"
                  Width="70"
                  Margin="10"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=JointConditionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=JointCondition3Index,
                                          Mode=TwoWay}" />
        <!--  Course End Date  -->
        <TextBlock Grid.Row="6"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.CourseEndDateField,
                                  Source={StaticResource ApplicationResources}}" />
        <StackPanel Grid.Row="6"
                    Grid.Column="1"
                    Orientation="Horizontal">
            <ComboBox Width="50"
                      Margin="10,10,0,10"
                      HorizontalAlignment="Left"
                      VerticalAlignment="Center"
                      ItemsSource="{Binding Path=CompareOperator,
                                            Mode=OneWay}"
                      SelectedIndex="{Binding Path=CourseEndDateCompareOperatorIndex,
                                              Mode=TwoWay}" />
            <DatePicker Width="140"
                        Margin="10"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        SelectedDate="{Binding Path=CourseEndDate,
                                               Mode=TwoWay}" />
        </StackPanel>
        <ComboBox Grid.Row="6"
                  Grid.Column="2"
                  Width="100"
                  Margin="10"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=ListSortDirectionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=CourseEndDateSortDirectionIndex,
                                          Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding Path=CourseEndDateSortDirectionSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <TextBlock Grid.Row="6"
                   Grid.Column="3"
                   Width="10"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=CourseEndDateSortOrder,
                                  Mode=OneWay}" />
        <!--  Joint Condition 4  -->
        <TextBlock Grid.Row="7"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.JointCondition,
                                  Source={StaticResource ApplicationResources}}" />
        <ComboBox Grid.Row="7"
                  Grid.Column="1"
                  Width="70"
                  Margin="10"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=JointConditionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=JointCondition4Index,
                                          Mode=TwoWay}" />
        <!--  Class Size  -->
        <TextBlock Grid.Row="8"
                   Grid.Column="0"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Strings.CourseClassSizeField,
                                  Source={StaticResource ApplicationResources}}" />
        <StackPanel Grid.Row="8"
                    Grid.Column="1"
                    Orientation="Horizontal">
            <ComboBox Width="50"
                      Margin="10,10,0,10"
                      HorizontalAlignment="Left"
                      VerticalAlignment="Center"
                      ItemsSource="{Binding Path=CompareOperator,
                                            Mode=OneWay}"
                      SelectedIndex="{Binding Path=ClassSizeCompareOperatorIndex,
                                              Mode=TwoWay}" />
            <TextBox Width="140"
                     Margin="10"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     Text="{Binding ClassSize,
                                    Mode=TwoWay}" />
        </StackPanel>
        <ComboBox Grid.Row="8"
                  Grid.Column="2"
                  Width="100"
                  Margin="10"
                  VerticalAlignment="Center"
                  DisplayMemberPath="DisplayName"
                  ItemsSource="{Binding Path=ListSortDirectionCollection,
                                        Mode=OneWay}"
                  SelectedIndex="{Binding Path=ClassSizeSortDirectionIndex,
                                          Mode=TwoWay}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding Path=ClassSizeSortDirectionSelectionChangedCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <TextBlock Grid.Row="8"
                   Grid.Column="3"
                   Width="10"
                   Margin="10"
                   VerticalAlignment="Center"
                   Text="{Binding Path=ClassSizeSortOrder,
                                  Mode=OneWay}" />

        <!--  Buttons  -->
        <StackPanel Grid.Row="9"
                    Grid.ColumnSpan="4"
                    Margin="0,20"
                    HorizontalAlignment="Center"
                    Orientation="Horizontal">
            <Button Width="90"
                    Margin="10, 2"
                    Command="{Binding Path=OkCommand}"
                    Content="{Binding Path=Strings.ButtonOK,
                                      Source={StaticResource ApplicationResources}}" />
            <Button Width="90"
                    Margin="10, 2"
                    Command="{Binding Path=CancelCommand}"
                    Content="{Binding Path=Strings.ButtonCancel,
                                      Source={StaticResource ApplicationResources}}" />
            <Button Width="90"
                    Margin="10, 2"
                    Command="{Binding Path=SaveDefaultCommand}"
                    Content="{Binding Path=Strings.ButtonSaveAsDefault,
                                      Source={StaticResource ApplicationResources}}" />
            <Button Width="90"
                    Margin="10, 2"
                    Command="{Binding Path=ResetCommand}"
                    Content="{Binding Path=Strings.ButtonReset,
                                      Source={StaticResource ApplicationResources}}" />
        </StackPanel>
    </Grid>
</extToolkit:ChildWindow>

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