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
339
Style and Dependency Property Question
posted

I have a problem where I'd like to override the "BackgroundSelected" DP of the DataRecordCellArea class with my own implementation. e.g.

            <Style x:Key="rowStyle" TargetType="{x:Type igDP:DataRecordCellArea}">
                    <Setter Property="BackgroundSelected" Value="{Binding ElementName=ucMyDataGrid, Path=SelectedRowBackgroundColor}" />
            </Style>

This works fine when the property "SelectedRowBackgroundColor" has been set, but when it's value is still null I would like to use the original value of DP "BackgroundSelected", that the underlying Theme applied. Shouldn't this be possible with a dependency property?

I've also tried referencing the theme's style for DataRecordCellArea, but the style's "setters" collection doesn't let you reference a setter by property name, only index.

Any ideas appreciated,

Jamie

Parents
No Data
Reply
  • 6867
    Verified Answer
    posted

    You could try using an IValueConverter on that Binding.  The converter would return Binding.DoNothing if your BackgroundSelected property has not been set.  Returning Binding.DoNothing from a value converter basically tells WPF to not push any value to the binding source/target.  It cancels the operation, which should allow the default color to be picked up.

    Josh

Children