Search code examples
c#wpfwpfdatagridimultivalueconverter

How to use the IsSelected property of the row in a converter?


I have a datagrid and I am using this multivalue converter:

<DataGrid.RowStyle>
    <Style TargetType="DataGridRow">

        <Setter Property="Background">
            <Setter.Value>
                <MultiBinding Converter="{StaticResource ucComponentesDataGridComponentesBackgroundFilaMultiValueConverter}">
                    <MultiBinding.Bindings>
                        <Binding />
                        <Binding Path="IsSelected"/>
                    </MultiBinding.Bindings>
                </MultiBinding>
            </Setter.Value>
        </Setter>

But in this way I can´t get the IsSelected property of the row. How can I use the property in my multi value converter?


Solution

  • Well, the solution is replace this line:

    <Binding Path="IsSelected"/>
    

    for this one:

    <Binding RelativeSource="{RelativeSource Self}" Path="IsSelected"/>