Click here to Skip to main content
15,896,606 members

DataGrid Calendar of WPF is not responding to Mouse click.

MohammadIqbal asked:

Open original thread
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
Tags: C# (C# 4.0), WPF, DataGrid, Microsoft Access

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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