WPF RadGridView containing RadDatePicker - How to change Style of date picker upon Trigger of GridViewRow IsSelected

1 posts, 0 answers
  1. Joe
    Joe avatar
    3 posts
    Member since:
    Oct 2012

    Posted 11 Feb 2013 Link to this post

    Specifically i want to change the background color of the RadDatePicker (as well as the whole row) when i am changing the currently selected row with the up/down arrow keys.

    To change the color of current row (highlighted) is achieved somewhat using Style.Triggers as per the following code:

    <telerik:RadGridView Name="tlrkGridView" 
                         IsFilteringAllowed="False" ShowGroupPanel="False" CanUserSortColumns="False" IsSynchronizedWithCurrentItem="True"
                         ItemsSource="{Binding Players}"
            <Style TargetType="{x:Type telerik:GridViewRow}">
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Background" Value="AliceBlue"></Setter>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding StartDate}" DataFormatString="{} {0: d/MM/yyyy}" Header="Custom Header">
                        <telerik:RadDatePicker x:Name="datePicker" DateTimeWatermarkContent="<Select a date>" SelectedValue="{Binding StartDate, Mode=OneWay}" />
                        <telerik:RadDatePicker x:Name="datePickerEdit" DateTimeWatermarkContent="<Select a date>" SelectedValue="{Binding StartDate, Mode=TwoWay}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding EndDate}" DataFormatString="{} {0: d/MM/yyyy}"  />
            <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ClubID}" 
                                            ItemsSource="{Binding Clubs, Source={StaticResource MyViewModel}}"
                                            SelectedValueMemberPath="ID" >
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            <TextBlock Text="{Binding ID}"/>
                            <TextBlock Text=" - " Grid.Column="1"/>
                            <TextBlock Text="{Binding Name}"  Grid.Column="2"/>

    But HOW TO MAKE THE TRIGGER AFFECT/SET THE STYLE OF THE RadDatePicker which is contained within the RadGridView? Is it do-able in XAML ?

    Basically i want to make the color of a selected row (the whole row) the same, regardless of whether it contains default column types, or other controls within a column. The GridViewComboBoxColumn behaves as expected, and EndDate field in my example behaves as expected. The reason i am using a RadDatePicker is because i want to show the Calendar icon in cell view mode.
Back to Top