Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi friends,

I have a DataGrid in WPF. which is binded to a MS Access DataBase. one of its column is DateTime type. and its heading name is "DOB".

Now I want to embeds the calender in my DataGrid cell. so that I can enter the Date by clicking on appropriate cells in the Calender.I was able to display the calender but unfortunately the calender always shows 2012 and it do not respond the mouse click. ie as expected when we click a cell in the DataGrid a pop up calender will appear. which have both front and back arrows, while clicking this arrow it should go to next or previous year.

Similarly when we click on a cell that particular Date should appear in the Datagrid cell. this is not happening . exactly I am getting a Dead Calender.

I am giving the code for resource dictionary and mainwindow.xaml respectively
HTML
<Style TargetType="{x:Type dg:Calendar}" x:Key="CalenderControlTemplate">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dg:Calendar" >
                    <dg:CalendarItem Name="myCalendarItem" 
                                 removed="Yellow" 
                                 BorderBrush="Black"
                                 BorderThickness="1"
                                 VerticalAlignment="Center" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate x:Key="EffDateDateTimePickerControl">
       
        <TextBlock Text="{Binding DOB, StringFormat=d}"  />
    </DataTemplate>

    <DataTemplate x:Key="addrEffDate">
        <dg:DatePicker x:Name="dpEffDate" Text="{Binding Path=effectiveDate,Mode=TwoWay}"
     
                     SelectedDate ="{Binding DOB}" SelectedDateFormat="Short"
                   
                   CalendarStyle="{DynamicResource CalenderControlTemplate}" />
    </DataTemplate>

for mainwindow.xaml the code is given below
HTML
<dg:DataGridTemplateColumn CellEditingTemplate ="{StaticResource addrEffDate}" CellTemplate="{StaticResource  EffDateDateTimePickerControl}"  Header="Effective Date">
               
            </dg:DataGridTemplateColumn>
         
        </dg:DataGrid.Columns>

please somebody help to resolve this

Regards
Iqbal
Posted
Updated 31-Jan-12 8:22am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900