Silverlight-Based Daily Construction Schedule Report Implementation

The user interface for the Silverlight-based construction schedule report is built using XAML with a focus on dynamic grid rendering within a themed container. The layout leverages the BubbleCremeTheme from the Silverlight 4 Toolkit, requiring proper namespace declaration:

<UserControl 
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:BubbleCremeTheme="System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.BubbleCremeTheme">
    <toolkit:BubbleCremeTheme>
        <StackPanel>
            <TextBlock x:Name="txtTitle" Text="Title" />
            <StackPanel Orientation="Horizontal">
                <Button Content="Mark All as Complete" Click="btnFilishAll_Click" />
                <Button Content="Full Screen" Click="BtnFullScreen_Click" />
                <Button Content="Submit" Click="Button_Click" />
            </StackPanel>
            <ScrollViewer>
                <Border BorderBrush="#FF333333" BorderThickness="2">
                    <Grid x:Name="gdPlans" MouseRightButtonDown="gdPlans_MouseRightButtonDown" />
                </Border>
            </ScrollViewer>
        </StackPanel>
    </toolkit:BubbleCremeTheme>
</UserControl>

The core data structure consists of three classes: PlansData, Plan, and PlanDate. Thece define hierarchical schedule entries with configurable date ranges, editabiilty flags, completion status, and validation rules:

public class PlansData
{
    public List<Plan> LstPlan { get; set; }
    public List<PlanDate> LstPlanDate { get; set; }
}

public class Plan
{
    public string PlanName { get; set; }
}

public class PlanDate
{
    public string Explain { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public bool IsReadOnly { get; set; }
    public bool IsFlish { get; set; } // Note: Typo preserved from original ("Flish" instead of "Finish")
    public bool HasEdit { get; set; }
    public bool AllowBlank { get; set; }
    public string Tag { get; set; }
}

Initialization parameters are passed via InitParams in the hosting ASPX page:

<param name="initParams" value="<%=InitParams %>" />

These parameters configure display settings (title, date range type, column counts) and supply URL-encoded JSON data. The Silverlight control parses these during initialization:

private void SetInitialValue()
{
    // Set defaults
    StartDate = DateTime.Now;
    DateType = "day";
    DateColCount = 30;
    
    // Process InitParams dictionary
    var initParams = App.Current.Host.InitParams;
    if (initParams.ContainsKey("Title"))
        txtTitle.Text = initParams["Title"];
        
    if (initParams.ContainsKey("Data"))
        LstPlansData = JsonConvert.DeserializeObject<List<PlansData>>(
            HttpUtility.UrlDecode(initParams["Data"])
        );
}

Sample data generation in the ASPX code-behind demonstrates how to construct schedule entries with multiple timeframes (baseline, planned, actual):

var plans = new List<PlansData>
{
    new PlansData
    {
        LstPlan = new List<Plan> { new Plan { PlanName = "Drywall Installation" } },
        LstPlanDate = new List<PlanDate>
        {
            new PlanDate { 
                StartDate = DateTime.Today, 
                EndDate = DateTime.Today.AddDays(3),
                Explain = "Baseline",
                IsReadOnly = true
            },
            new PlanDate { 
                StartDate = DateTime.Today.AddDays(1), 
                EndDate = DateTime.Today.AddDays(4),
                Explain = "Planned",
                CanGreaterThanNow = true
            }
        }
    }
};
InitParams = $"Title=Construction Schedule,Data={HttpUtility.UrlEncode(JsonConvert.SerializeObject(plans))}";

Data deserialization uses Json.NET's Silverlight-compatible library to convert the transmitted JSON string into strongly-typed objects for UI rendering.

Tags: Silverlight JSON.NET XAML Theming DataBinding

Posted on Tue, 09 Jun 2026 16:56:08 +0000 by Slip