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
785
Accessing a Row Number From Within a CellValuePresenter Style
posted

Hello,

I took the default style for CellValuePresenter from DataPresenterGeneric_Express.xaml and am modifying it. Among other things, I'm setting the background color of a cell by using a value converter:

 <Style TargetType="{x:Type igDP:CellValuePresenter}">
   <Setter Property="Background"
        Value="{Binding Path=Value, Converter={StaticResource cellColorFromDetectionDataTypeConverter},
        RelativeSource={RelativeSource Self}}"/>

I would now like to use the "parameter" parameter to the value converter. Specifically, I'd like to pass the row number to the converter. How may I alter my xaml to do so?

 

Thanks,

Dave

 

  • 69686
    posted

    Hello Dave,

    You can use a IMultiValueConverter instead of IValueConverter and you can pass both the value and the record index.

    You can see an example of a similar approach here.

  • 785
    posted

    I'll elaborate and make a general statement of what I'm trying to do: I want to set a cell's background color based on its content, row number, and column number. My original post is an obvious attempt to do that, and I'd still like to go that route if possible. However, I would also be glad to hear suggestions other than using a value converter to achieve my goal.