Hi,
I tried to create a method that set the color of a DataGridCell calculating it.
I created a resource that use this method:
<UserControl.Resources>
<ObjectDataProvider ObjectType="{x:Type l:D}"
MethodName="CalculateBackColor" x:Key="CalculateBackColor">
<ObjectDataProvider.MethodParameters>
<system:Object/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</UserControl.Resources>
NB: I used an Object parameter because I tried to pass the cell itself or the DataGridCellInfo, but I don't know how. I used Object only for attempts. In a future, it will be
<ObjectDataProvider.MethodParameters>
<DataGridCell/>
</ObjectDataProvider.MethodParameters>
I tried to bind this method to the background of the cell.
<DataGrid IsReadOnly="True" ItemsSource="{Binding}">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Me" Value="{Binding
Source={StaticResource ResourceKey=FromDRToColor},
Path=MethodParameters[0], BindsDirectlyToSource=True}" />
<Setter Property="Background" Value="{Binding
Source={StaticResource ResourceKey=FromDRToColor}}"/>
</Style>
</DataGrid.CellStyle>
</DataGrid>
Naturally, Setter Property = "Me" doesn't run.
Even inserting Setter Property = "Content" instead of "Me", the function receives as a parameter a null (perhaps because even the content has not been set, or maybe because I was wrong syntax)
How do I have to do?