Foreground by rowstyleselector

5 posts, 0 answers
  1. Fernan
    Fernan avatar
    15 posts
    Member since:
    May 2010

    Posted 01 Mar Link to this post

    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,

  2. Fernan
    Fernan avatar
    15 posts
    Member since:
    May 2010

    Posted 01 Mar Link to this post

    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!

  3. UI for WPF is Visual Studio 2017 Ready
  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 02 Mar Link to this post

    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
  5. Fernan
    Fernan avatar
    15 posts
    Member since:
    May 2010

    Posted 02 Mar in reply to Stefan Nenchev Link to this post

    Hi,

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

     

    Thanks,

  6. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 02 Mar Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready