none
Silverligh Timesheet app

    Question

  •  I am currently building a timesheet system using RIA Services and the Silverlight Business Application, and iam currently displaying on a particular page a Datagrid bound to a Collection of Task Entities and for each entity a collection of Time Entities.

     

    Task meta data is as follows:

     internal sealed class TaskMetadata
            {

                // Metadata classes are not meant to be instantiated.
                private TaskMetadata()
                {
                }

                public string description { get; set; }

                public string name { get; set; }

                public EntityCollection<OTSUser> OTSUsers { get; set; }

                [Include]
                public Project Project { get; set; }

                public int projectid { get; set; }

                public int taskid { get; set; }
               
                [Include]
                public EntityCollection<Time> Times { get; set; }
            }

    ZAML for Timesheet page

    <navigation:Page x:Class="Ingena.OTS.Views.Timesheets"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:local="clr-namespace:Ingena.OTS.Views"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:ds="clr-namespace:Ingena.OTS.Web"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     mc:Ignorable="d"
                     xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
                     xmlns:ex="clr-namespace:Ingena.OTS.Controls;assembly=Ingena.OTS.Controls"
                     xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
                     xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                     d:DesignWidth="640" d:DesignHeight="480"
                     Title="Timesheets Page">
        <navigation:Page.Resources>
            <local:DayOfWeekConverter x:Key="DayOfWeekConverter"/>
        </navigation:Page.Resources>
        <Grid x:Name="LayoutRoot">
            <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}" >
                <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">
                    <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}"
                               Text="Timesheets"/>
                    <riaControls:DomainDataSource Name="domainClient" LoadSize="20" QueryName="GetClients" AutoLoad="True">
                        <riaControls:DomainDataSource.DomainContext>
                            <ds:OTSDomainContext/>
                        </riaControls:DomainDataSource.DomainContext>
                    </riaControls:DomainDataSource>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <TextBlock VerticalAlignment="Center" Text="Week Ending"/>
                        <ComboBox Name="WEComboBox" Width="75" FontSize="11" Margin="4"/>
                    </StackPanel>
                    <sdk:DataGrid Name="dgTimesheets" MinHeight="100" IsReadOnly="True" Height="Auto" AutoGenerateColumns="False">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="Client">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Project.clientid}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Project">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Project.title}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Task">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding name}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Monday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Monday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Tuesday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Tuesday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Wednesday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Wednesday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Thursday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Thursday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Friday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Friday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Saturday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Saturday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Sunday">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Sunday}" Text="{Binding workinghours}" Margin="4"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                    <dataForm:DataForm x:Name="dfTimesheet"
                                       Header="Timesheet Information" 
                                       AutoGenerateFields="False"
                                       AutoEdit="False"
                                       AutoCommit="False"
                                       CurrentItem="{Binding SelectedItem, ElementName=dgTimesheets}"
                                       Margin="0,12,0,0">                       
                        <dataForm:DataForm.EditTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <dataForm:DataField Label="Client ID">
                                        <TextBox IsReadOnly="True" Text="{Binding Project.clientid, Mode=OneWay}" />
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Project">
                                        <!--ComboBox Name="ProjectComboBox" ItemsSource="{Binding Project, Mode=TwoWay, NotifyOnValidationError=True,  ValidatesOnExceptions=True}" DisplayMemberPath="organisation" /-->
                                        <TextBox IsReadOnly="True" Text="{Binding Project.title, Mode=OneWay}" />
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Task">
                                        <TextBox IsReadOnly="True" Text="{Binding name, Mode=OneWay}" />
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Times">
                                        <TextBox IsReadOnly="True" Text="{Binding Times, Mode=OneWay}" />
                                        <!--ComboBox Name="TimesComboBox" ItemsSource="{Binding Times, Mode=TwoWay}"/-->
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Monday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Monday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Tuesday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Tuesday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>   
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Wednesday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Wednesday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Thursday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Thursday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Friday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Friday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Saturday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Saturday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                    <dataForm:DataField Label="Sunday">
                                        <TextBox DataContext="{Binding Converter={StaticResource DayOfWeekConverter}, ConverterParameter=Sunday}" Text="{Binding workinghours, Mode=TwoWay}" Margin="4"/>
                                    </dataForm:DataField>
                                </StackPanel>
                            </DataTemplate>
                        </dataForm:DataForm.EditTemplate>
                    </dataForm:DataForm>
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </navigation:Page>

    Tuesday, August 17, 2010 8:50 PM

All replies