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

Updating RowSelector style following a sort

Sort Posts: Previous Next
  •  04-26-2012, 4:57 AM Post no. 32036

    Updating RowSelector style following a sort

    Hi,

     I have a DataGrid and I apply a style to the selector row which is defined below. This sets the border colour depending on the status of the data in the row.

              <Style x:Key="rowSelectorStyle" TargetType="{x:Type xcdg:RowSelector}">

                <Style.Setters>

                    <EventSetter Event="MouseEnter" Handler="OnRowSelectorMouseEnter"/>

                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="OnRowSelectorPreviewMouseLeftButtonDown"/>

                    <Setter Property="BorderThickness" Value="1"/>

                    <Setter Property="Margin" Value="1"/>

                    <Setter Property="Padding" Value="2"/>

                    <Setter Property="BorderBrush" >

                        <Setter.Value>

                            <MultiBinding Converter="{StaticResource fieldStatusToBrushConverter}">

                                <Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" />

                                <Binding Mode="OneWay" RelativeSource="{RelativeSource Self}" Path="DataContext" />

                            </MultiBinding>

                        </Setter.Value>

                    </Setter>

                </Style.Setters>

             </Style>

     This works fine until I sort the rows using the built in sort by clicking on a column. The causes the rows to be re-ordered but the style for each row does not seem to update to match the new position of the data.

    If I force row recycling by scrolling the grid then it seems the style gets applied correctly i.e. the row selector border is applied to the correct rows.

     Is it possible to ensure the style gets refreshed when sorting rows? I have tried reapplying the style for each row on ItemsSourceChangeCompleted event but this does not resolve the issue.

     Many Thanks

     Pete 

  •  04-28-2012, 5:16 PM Post no. 32047 in reply to 32036

    Re: Updating RowSelector style following a sort

    Hi Pete,

    Are you able to send me a small self-contained sample application that shows this behavior? With your code, I will be able to answer your question based off of your exact scenario. 


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  05-10-2012, 5:14 PM Post no. 32095 in reply to 32047

    Re: Updating RowSelector style following a sort

    Hi,

    Please find attached a simple test application that demonstrates the issue with the row selector style getting detached from the correct DataRow. The red border should be displayed  if the first column is empty – the first row  on startup.

     Sorting works at first but keep sorting and it’ll soon go wrong.

    Thanks

     Pete 

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