This is a migrated thread and some comments may be shown as answers.

Foreground by rowstyleselector

4 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fernan
Top achievements
Rank 1
Fernan asked on 01 Mar 2016, 09:01 AM

Hi,

I have a GridView for a DesktopAlert. It is like the example in your demos. 

I have used the RowStyleSelector from the example. The properties "FontWeight" and "Background" work succesfull, however the property "Foreground" doesn't work. The color of text of the row is not changing. 

The code:

 

<UserControl.Resources>
       <localStyleSelector:MessageRowStyleSelector x:Key="RowStyleSelector">
           <localStyleSelector:MessageRowStyleSelector.BoldStyle>
               <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}">
                   <Setter Property="FontWeight" Value="Bold" />
                   <Setter Property="Background" Value="#FF9EAABF" />
                   <Setter Property="Background" Value="Red" />
               </Style>
           </localStyleSelector:MessageRowStyleSelector.BoldStyle>
           <localStyleSelector:MessageRowStyleSelector.NormalStyle>
               <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}" />
           </localStyleSelector:MessageRowStyleSelector.NormalStyle>
       </localStyleSelector:MessageRowStyleSelector>
       <localConverter:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
   </UserControl.Resources>

 

<telerik:RadGridView x:Name="gwMessages"
    ScrollViewer.VerticalScrollBarVisibility="Auto"                     
    Grid.Row="1"
    Grid.Column="0"
    ShowGroupPanel="False"
    SelectionChanged="OnGridViewSelectionChanged"
    ItemsSource="{Binding ReceivedMessagesCollection}"
    SelectedItem="{Binding SelectedMessage, Mode=TwoWay}"
    IsSynchronizedWithCurrentItem="True"
    RowStyleSelector="{StaticResource RowStyleSelector}"
    GroupRenderMode="Flat"
    AutoExpandGroups="True"
    AutoGenerateColumns="False"
    RowIndicatorVisibility="Collapsed"
    CanUserFreezeColumns="False"
    IsReadOnly="True"                   
    ColumnWidth="*">
    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu>
            <telerik:EventToCommandBehavior.EventBindings>
                <telerik:EventBinding Command="{Binding ContextMenuOpenedCommand}" EventName="Opened" PassEventArgsToCommand="True" />
            </telerik:EventToCommandBehavior.EventBindings>
            <telerik:RadMenuItem Header="Reply" />
            <telerik:RadMenuItem Header="Reply All" />
            <telerik:RadMenuItem Header="Forward" />
            <telerik:RadMenuItem IsSeparator="True" />
            <telerik:RadMenuItem Header="Mark as Unread" Command="{Binding MarkAsUnread_ContextMenuCommand}" />
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="From" DataMemberBinding="{Binding Sender}" />
        <telerik:GridViewDataColumn Header="Subject" DataMemberBinding="{Binding Subject}" />
        <telerik:GridViewDataColumn Header="Received" DataMemberBinding="{Binding Received}" DataFormatString=" {0:dd/MM/yyyy hh:mm}" />
        <telerik:GridViewDataColumn Header="ReceivedDate" DataMemberBinding="{Binding ReceivedDate}" IsVisible="False" GroupHeaderFormatString=" {0:dd/MM/yyyy}" DataFormatString=" {0:dd/MM/yyyy}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

 

Any help?

 

Thanks,

4 Answers, 1 is accepted

Sort by
0
Fernan
Top achievements
Rank 1
answered on 01 Mar 2016, 09:04 AM

Sorry, the correct code is the following:

 

<UserControl.Resources>
    <localStyleSelector:MessageRowStyleSelector x:Key="RowStyleSelector">
        <localStyleSelector:MessageRowStyleSelector.BoldStyle>
            <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}">
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="Background" Value="#FF9EAABF" />
                <Setter Property="Foreground" Value="Red" />
            </Style>
        </localStyleSelector:MessageRowStyleSelector.BoldStyle>
        <localStyleSelector:MessageRowStyleSelector.NormalStyle>
            <Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}" />
        </localStyleSelector:MessageRowStyleSelector.NormalStyle>
    </localStyleSelector:MessageRowStyleSelector>
    <localConverter:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources>

 

<telerik:RadGridView x:Name="gwMessages"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"                     
                  Grid.Row="1"
                  Grid.Column="0"
                  ShowGroupPanel="False"
                  SelectionChanged="OnGridViewSelectionChanged"
                  ItemsSource="{Binding ReceivedMessagesCollection}"
                  SelectedItem="{Binding SelectedMessage, Mode=TwoWay}"
                  IsSynchronizedWithCurrentItem="True"
                  RowStyleSelector="{StaticResource RowStyleSelector}"
                  GroupRenderMode="Flat"
                  AutoExpandGroups="True"
                  AutoGenerateColumns="False"
                  RowIndicatorVisibility="Collapsed"
                  CanUserFreezeColumns="False"
                  IsReadOnly="True"                   
                  ColumnWidth="*">
                  <telerik:RadContextMenu.ContextMenu>
                      <telerik:RadContextMenu>
                          <telerik:EventToCommandBehavior.EventBindings>
                              <telerik:EventBinding Command="{Binding ContextMenuOpenedCommand}" EventName="Opened" PassEventArgsToCommand="True" />
                          </telerik:EventToCommandBehavior.EventBindings>
                          <telerik:RadMenuItem Header="Reply" />
                          <telerik:RadMenuItem Header="Reply All" />
                          <telerik:RadMenuItem Header="Forward" />
                          <telerik:RadMenuItem IsSeparator="True" />
                          <telerik:RadMenuItem Header="Mark as Unread" Command="{Binding MarkAsUnread_ContextMenuCommand}" />
                      </telerik:RadContextMenu>
                  </telerik:RadContextMenu.ContextMenu>
                  <telerik:RadGridView.Columns>
                      <telerik:GridViewDataColumn Header="From" DataMemberBinding="{Binding Sender}" />
                      <telerik:GridViewDataColumn Header="Subject" DataMemberBinding="{Binding Subject}" />
                      <telerik:GridViewDataColumn Header="Received" DataMemberBinding="{Binding Received}" DataFormatString=" {0:dd/MM/yyyy hh:mm}" />
                      <telerik:GridViewDataColumn Header="ReceivedDate" DataMemberBinding="{Binding ReceivedDate}" IsVisible="False" GroupHeaderFormatString=" {0:dd/MM/yyyy}" DataFormatString=" {0:dd/MM/yyyy}" />
                  </telerik:RadGridView.Columns>
              </telerik:RadGridView>

 

Any help?

 

Thanks!

0
Stefan Nenchev
Telerik team
answered on 02 Mar 2016, 11:20 AM
Hi Fernando,

I have tried reproducing the issue you are experiencing but was not able to. Though you have not provided the full implementation of the StyleSelector, the approach you are using seems fine. Still, you can check the RadGridView - RowStyleSelector demo in our SDK Samples Browser which you can download from here - http://demos.telerik.com/xaml-sdkbrowser/

Can you please update me what is the theme that you have set for your application? Do you have any additional styles applied that might be affecting the GridViewRow`s Foreground? Recently, we had a bug related to the GreenTheme where the ForeGround property of the GridViewRow could not be changed so you might be affected by it. Please update me if this is the case. 

Regards,
Stefan Nenchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Fernan
Top achievements
Rank 1
answered on 02 Mar 2016, 11:29 AM

Hi,

Indeed, I am using the GreenTheme. Is there any workaround?

 

Thanks,

0
Stefan Nenchev
Telerik team
answered on 02 Mar 2016, 03:23 PM
Hello Fernando,

The bug has already been reviewed and a fix is available with the latest internal build. You can find more information on the following page - Using the Hotfix(DLLs Only).

Regards,
Stefan Nenchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Fernan
Top achievements
Rank 1
Answers by
Fernan
Top achievements
Rank 1
Stefan Nenchev
Telerik team
Share this question
or