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}"
                         AutoGenerateColumns="False">
        <telerik:RadGridView.RowStyle>
            <Style TargetType="{x:Type telerik:GridViewRow}">
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Background" Value="AliceBlue"></Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </telerik:RadGridView.RowStyle>
        <telerik:RadGridView.Columns>
            <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:GridViewDataColumn.CellTemplate>
                    <DataTemplate>
                        <telerik:RadDatePicker x:Name="datePicker" DateTimeWatermarkContent="<Select a date>" SelectedValue="{Binding StartDate, Mode=OneWay}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellTemplate>
                <telerik:GridViewDataColumn.CellEditTemplate>
                    <DataTemplate>
                        <telerik:RadDatePicker x:Name="datePickerEdit" DateTimeWatermarkContent="<Select a date>" SelectedValue="{Binding StartDate, Mode=TwoWay}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellEditTemplate>
            </telerik:GridViewDataColumn>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding EndDate}" DataFormatString="{} {0: d/MM/yyyy}"  />
            <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ClubID}" 
                                            ItemsSource="{Binding Clubs, Source={StaticResource MyViewModel}}"
                                            SelectedValueMemberPath="ID" >
                <telerik:GridViewComboBoxColumn.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding ID}"/>
                            <TextBlock Text=" - " Grid.Column="1"/>
                            <TextBlock Text="{Binding Name}"  Grid.Column="2"/>
                        </Grid>
                    </DataTemplate>
                </telerik:GridViewComboBoxColumn.ItemTemplate>
            </telerik:GridViewComboBoxColumn>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

    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