RadDatePicker not binding current date

4 posts, 0 answers
  1. Pranavi
    Pranavi avatar
    8 posts
    Member since:
    Jul 2013

    Posted 20 Aug 2013 Link to this post

    hi 

    I was added RadDatePicker to Footer with below code i want to display the default  Current date as "System.Date.Now";  but the date is not binding to that footer .

    the same RadDatePicker i have in my form and i need to bind the same thing "System.Date.Now" it is binding but in footer it is not binding please help me


    <TelerikGrid:GridViewDataColumn  Header="Qty1" MinWidth="100" Width="110"  TextAlignment="Right" DataMemberBinding="{Binding Qty1, Mode=TwoWay}" DataFormatString="{}{0:N2}">
                                                              <TelerikGrid:GridViewDataColumn.Footer>
                                                                    <StackPanel Orientation="Vertical" Height="50" HorizontalAlignment="Left">
                                                                        <telerikInput:RadDatePicker x:Name="dt" HorizontalAlignment="Center"  SelectedValue="{Binding dat}" Margin="11,0,0,0" />
                                                                        <CheckBox  Height="16" Name="checkBox1"   IsChecked="{Binding Path=CurrentItem.InActive,Mode=TwoWay}" HorizontalAlignment="Center" />
                                                                    </StackPanel>
                                                                </TelerikGrid:GridViewDataColumn.Footer>
                                                               </TelerikGrid:GridViewDataColumn>

  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 20 Aug 2013 Link to this post

    Hi Pranavi,

    The used binding is not working because the GridViewDataColumn has different DataContext than the DataContext of the application. So one way to resolve this is to set the DataContext of the DatePicker to the same ViewModel that you use. Another way to go is to set it directly in XAML, you can achieve this by adding the following namespace:
    xmlns:sys="clr-namespace:System;assembly=mscorlib"

    And then you only need to set the SelectedValue as follows:
    SelectedValue="{x:Static sys:DateTime.Now}"

    Hope this helps.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pranavi
    Pranavi avatar
    8 posts
    Member since:
    Jul 2013

    Posted 21 Aug 2013 Link to this post

    SelectedValue="{x:Static sys:DateTime.Now}"

    the above statement is showing like  "Static is not supported in Silverlight project"
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 21 Aug 2013 Link to this post

    Hello Pranavi,

    It works only in WPF applications. However here is another solution which uses the same DataContext as the GridView, just set the binding as the example below and should work as required:

    SelectedValue="{Binding DataContext.dat, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadGridView}}"

    I hope this will work for you.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top