Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
RecordSelector row selected styling
posted

Hi,

I've been styling the RecordSelector for the XamDataGrid, and so far so good. I've got the colours changing when the mouse is over and when the row is active. What I now need is to change the colour when the row is selected by clicking the RecordSelector, but I can't see a property to hook into. Here's what I've got so far:

<Style TargetType="{x:Type DataPresenter:RecordSelector}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Border x:Name="SelectorBorder" BorderThickness="1,0,1,1" BorderBrush="#9eb6ce">
                    <Rectangle x:Name="SelectorBox" Fill="#e4ecf7" />
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="DataPresenter:RecordSelector.IsActive" Value="True">
                        <Setter TargetName="SelectorBorder" Property="BorderBrush" Value="#947749" />
                        <Setter TargetName="SelectorBox" Property="Fill" Value="{StaticResource SelectorRowActiveBrush}" />
                    </Trigger>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter TargetName="SelectorBorder" Property="BorderBrush" Value="{StaticResource SelectorMouseOverBorderBrush}" />
                        <Setter TargetName="SelectorBox" Property="Fill" Value="{StaticResource SelectorMouseOverBoxBrush}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

What I'd like to add is a new set of colours when the selector is either clicked, or dragged over as part of a multi-selection. Is there anything like RecordSelector.IsSelected?

Cheers,

Adam

Parents
No Data
Reply
  • 69686
    Verified Answer
    posted

    Hello Adam,

    For this, you would have to target the Record and bind to its IsSelected property. If you create a DataTrigger, it will use the DataContext, which is the Record itself, so what you need to do is only this:

      <DataTrigger Binding="{Binding IsSelected}" Value="True">

         <Setter TargetName="SelectorBox" Property="Fill" Value="Yellow" />

     </DataTrigger>

    Hope this helps.

Children