Hello,
I'm trying your XamlGrid to substitute a Telerik one that goes under pressure with a lot of data and high frequency update. With no style it performs really well but now I need to test your under pressure with style selections.
The first thing I need to verify is that all the features I've under your competitor works fine here.
In my DTO I've got a field IdStatus that based on this value it colors the whole row of a color taken from DB.
Now consider the following Converter
public class StatusRowColorStyleSelectorBase : IValueConverter { protected Dictionary<int, SolidColorBrush> StatuStyles; public StatusRowColorStyleSelectorBase() { StatuStyles = new Dictionary<int, SolidColorBrush> { {(int) StatusTypeEnum.Inserted, CreateStyle("Transparent")}, {(int) StatusTypeEnum.Cancelled, CreateStyle("#ff4500")}, {(int) StatusTypeEnum.Validated, CreateStyle("#00bfff")}, {(int) StatusTypeEnum.Exported, CreateStyle("#90ee90")} }; } private static SolidColorBrush CreateStyle(string color) { var convertFromString = ColorConverter.ConvertFromString(color); if (convertFromString is Color c) { return new SolidColorBrush(c); } return new SolidColorBrush(Colors.Transparent); } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is IStatus status) { return StatuStyles[status.IdStatus]; } return value; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
And I've seen a sample where you do
<igDP:XamDataGrid Name="xamDataGrid1" BindToSampleData="True"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path= Record.Cells[1].Value}" Value="Sales" > <Setter Property="Background" Value="Orange" /> </DataTrigger> </Style.Triggers> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid>
In this code you check on Cell[1], what if the user reorders the column?
It's possible to pass to the converter the whole DataItem?
Hello Paolo,
Thank you for posting to our forum.
In order to understand the scenario I followed the code you provided and created a sample of my own.Now for both the questions I have information as :
1)When user reorder the column Cells[1].Value would still be same.If can also give the column name instead of passing the index like this: Cells[department].Value
2)Yes you can pass the whole DataItem to the converter but in this case if any property changes in the grid this converter would not fire.
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path= Record.Cells[1].Value}" Value="Sales" > I noticed, In this line of code “RelativeSource={RelativeSource Self}, Path= Record” code is redundant , you could just directly bind it like this:
<DataTrigger Binding="{Binding Cells[department].Value}" Value="Sales" >
Instead of passing the whole DataItem I would recommend you to pass the DataItem’s CustomProperty like this:
<DataTrigger Binding="{Binding DataItem.CustomProperty, Converter={StaticResource someKeyThatPointsAtAConverter}}" Value="Sales" > <Setter Property="Background" Value="Red" /></DataTrigger>
I have also attached a sample application for your reference.
Please find the attached sample and let me know if you need further assistance.
DataTrigger.zip
That's fine , but what about the blink? as I mentioned on the ticket I need to perform a blink when a field of the row is updated