Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how I can set a particular column as calender column which displays both time and date , in DataGrid of WPF
Posted

ok man you have to add a template field and inside this field you can add any control you want ex:
XML
<asp:TemplateField HeaderText="Date" >
        <ItemTemplate>
            <--Add here a date time controll or calendar--;" ></asp:TextBox>
        </ItemTemplate>
    </asp:TemplateField>
 
Share this answer
 
Comments
Shmuel Zang 16-Jan-12 3:54am    
Nice ASP.NET solution. But, this question is about WPF...

You can use a DataGridTemplateColumn for that purpose.


You can set the DataTemplate of your column, like the following:


XML
<DataGrid ItemsSource="{Binding MyObjectsProperty}">
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="My calendar column">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <!-- Replace following DataTemplate with a calendar DataTemplate -->
                    <Border BorderBrush="Blue" Background="LightBlue" BorderThickness="2" Padding="10">
                        <TextBlock Text="{Binding MyDateProperty}" />
                    </Border>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>
 
Share this answer
 

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



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