Welcome to the Xceed Community | Help
Community Search  
More Search Options

Preventing entire row being highlighted in a different colour when a cell or a row is selected

Sort Posts: Previous Next
  •  12-17-2009, 5:14 PM Post no. 25252

    Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Is there any way of setting up a DataGrid so that when a cell or a row is selected, it doesn't highlight the entire row in a different colour?

    I've looked at the following topics:

    As advised in those, I've set up a Style in my DataGridControl's container's resources:

                  <Style TargetType="{x:Type xcdg:DataRow}">
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
                        <Setter Property="SelectionBackground" Value="HotPink"/>
                        <Setter Property="SelectionForeground" Value="White"/>
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>

    But, this isn't having any effect though, and ultimately, I want to make the background not be changed at all.  Is this possible?


    Associate, .NET Development
    Morgan Stanley, UK
    Filed under: , , ,
  •  12-18-2009, 9:03 AM Post no. 25254 in reply to 25252

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Hello,

       You can apply the style to the DataCell which is selected and applying style for the Selection Background to be of the same color as it is in the normal mode.

    Also apply the same style for the DataRow which is selected.

    Thanks,

    Paras Sanghani 

     

     


    Nothing Is Impossible
  •  12-18-2009, 4:44 PM Post no. 25261 in reply to 25254

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Hi,

    You are most probably using the Aero Theme;  the Aero look does not use the "SelectionBackground" property, this is why your code did not have an effect. For the Aero theme, to change this, you will need to make a copy of the ControlTemplate for the DataRow (provided with the package) and modify it to your needs.

    Or if its possible, just change the theme and your code will work:

    <Window.Resources>

          <Style TargetType="xcdg:DataRow">
             <Setter Property="SelectionBackground"
                     Value="Red" />
             <Setter Property="SelectionForeground"
                     Value="Red" />
          </Style>

          <Style TargetType="xcdg:TableView">
             <Setter Property="Theme">
                <Setter.Value>
                   <xcdg:ClassicSystemColorTheme />
                </Setter.Value>
             </Setter>
          </Style>

    </Window.Resources> 

    Regards,

    Alain Jreij,

    Xceed Technical Support


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  01-04-2010, 4:43 PM Post no. 25328 in reply to 25261

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Thanks guys.  This helped.  It was the presence of the DataTrigger (<DataTrigger Binding="{Binding Path=IsSelected}" Value="True">) that was causing the problem.  I took this out, and all worked fine.  Not sure why I put that - obviously over-thinking the matter.

    Additionally, as this may help other people looking here, I was able to bind the Foreground to the Background using a Converter, and then bind the SelectionForeground to the Foreground using the following code:

    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Background, Converter={StaticResource backToFrontColorConverter}}" />

    <Setter Property="SelectionForeground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Foreground}" />


    Associate, .NET Development
    Morgan Stanley, UK
  •  01-04-2010, 4:49 PM Post no. 25329 in reply to 25328

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Hi Jason,

    Thank you for sharing your knowledge :)

    Alain,

    Xceed Technical Support


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  02-23-2011, 4:23 PM Post no. 29938 in reply to 25329

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Would the same be possible with the 3.1 version? It doesnt' seem to react on anything, and I can't change the theme with the free version. the code I have is the following

                    <xcdg:DataGridControl ItemsSource="{Binding Path=DataViewSurvivor}" Margin="4,4,4,4">
                        <xcdg:DataGridControl.Resources>
                            <Style TargetType="{x:Type xcdg:GroupByControl}">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </Style>
                            <Style TargetType="{x:Type xcdg:DataRow}">
                                <Setter Property="SelectionBackground" Value="Transparent" />
                                <Setter Property="SelectionForeground" Value="Transparent"/>
                            </Style>
                        </xcdg:DataGridControl.Resources>
                    </xcdg:DataGridControl>
    Thanks for your help
  •  02-24-2011, 2:33 PM Post no. 29944 in reply to 29938

    Re: Preventing entire row being highlighted in a different colour when a cell or a row is selected

    Hi Rudi,

    Using the free edition should not prevent you from being able to change the theme. For example, I tested this myself and the following code worked fine.

       <xcdg:DataGridControl ... >
          <xcdg:DataGridControl.View>
             <xcdg:TableView>
                <xcdg:TableView.Theme>
                   <xcdg:ClassicSystemColorTheme />
                </xcdg:TableView.Theme>
             </xcdg:TableView>
          </xcdg:DataGridControl.View>
       </xcdg:DataGridControl>

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.