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
35
CellStyleCelector with particular behavior + Blinking
posted

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?

Parents Reply Children