tags:

views:

52

answers:

0

Now my code is

    public class Leave
{
    public string wContId { get; set; }
    public DateTime wContratStartDate { get; set; }
    public DateTime wContratEndDate { get; set; }
    public string wNameFst { get; set; }
    public string wNameLst { get; set; }
    public string wEmpId { get; set; }
    public string wSeqId { get; set; }
    public DateTime wFmDt { get; set; }
    public DateTime wToDt { get; set; }
    public Decimal wNumDay { get; set; }
    public Boolean wNoPay { get; set; }
    public string wCrtBy { get; set; }
    public DateTime wCrtDt { get; set; }
}

public class LeaveData : List<Leave>
{
    public LeaveData()
    {
        this.Add(new Leave
        {
            wEmpId = "001",
            wContId = "K0012",
            wContratStartDate = DateTime.Now.AddMonths(-2),
            wContratEndDate = DateTime.Now.AddMonths(16),
            wNameFst = "Sayid",
            wNameLst = "Dekker",
            wSeqId = "1",
            wFmDt = DateTime.Now.AddDays(-30),
            wToDt = DateTime.Now.AddDays(-28),
            wNumDay = 2,
            wNoPay = false,
            wCrtBy = "samlin",
            wCrtDt = DateTime.Now.AddDays(-31)
        });

        this.Add(new Leave
        {
            wEmpId = "003",
            wContId = "L0189",
            wContratStartDate = DateTime.Now.AddMonths(-2),
            wContratEndDate = DateTime.Now.AddMonths(1),
            wNameFst = "Sonic",
            wNameLst = "Chiu",
            wSeqId = "1",
            wFmDt = DateTime.Now.AddDays(-28),
            wToDt = DateTime.Now.AddDays(-27),
            wNumDay = 1,
            wNoPay = false,
            wCrtBy = "samlin",
            wCrtDt = DateTime.Now.AddDays(-31)
        });
    }
}

and then I would like to put a resources in xaml

xmlns:leave="clr-namespace:ccHrms.Views.Leave"

Included the namespace

    <Grid x:Name="LayoutRoot">
    <Grid.Resources>
        <leave:LeaveData x:Key="LeaveData" />
    </Grid.Resources>

Added the resources

<dg:DataGrid x:Name="dgLeave" AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{StaticResource LeaveData}">

added the itemsource to the datagrid ...

But It didn't work, show nothing in the grid ...

when I put the LeaveData to DataForm, runtime error prompted!!

<df:DataForm x:Name="dfLeave" MinWidth="200" ItemsSource="{StaticResource LeaveData}">