Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF C#4.0 Access DataGrid
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
<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
 
<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 31-Jan-12 6:46am
Edited 31-Jan-12 9:22am
(no name)242.2K
v2

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

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 152
2 ProgramFOX 130
3 Maciej Los 130
4 den2k88 80
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100