We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to give alternative row background color in PivotGrid

XAML

 

C#

 

http://www.syncfusion.com/downloads/Support/DirectTrac/101390/clip_image001194063766.png

Figure: Pivot Grid shows alternate row backgrounds

 

Article ID: Published Date: Last Revised Date: Platform: Control:
2878 11/24/2014 11/26/2014 WPF PivotGridControl
Tags:
Did you find this information helpful?
Comments
Branden Boucher Feb 14, 2017
Where is MainWindow coming from? What is MainWindow supposed to be?
Reply
Sabaridass Ramamoorthy [Syncfusion] Feb 21, 2017

Hi Branden,

 

MainWindow is nothing but the current window of your application. And the “rowIdex” and “colIndex” are the static variables are defined in current window to access the cell values in PivotGrid control. Those static variables are re-assigned based on the current cell in TargetUpdated event handler method.

 

Please refer to the following code example:

#MainWindo.Xaml.cs

 

public partial class MainWindow : Window

    {

        public static int rowIdex;

        public static int colIndex;

 

private void Image_TargetUpdated(object sender, DataTransferEventArgs e)

        {

            var styleInfo = ((sender as Image).TemplatedParent as PivotGridTemplateCell).StyleInfo;

            rowIdex = styleInfo.RowIndex;

            colIndex = styleInfo.ColumnIndex;

        }

 

    }

public class BackColorConverter : IValueConverter

    {

 

        Brush brush = Brushes.White;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            Syncfusion.Windows.Controls.PivotGrid.PivotGridControl pivotGrid = value as Syncfusion.Windows.Controls.PivotGrid.PivotGridControl;

            int rowIndex = MainWindow.rowIdex;

            int colIndex = MainWindow.colIndex;

 

            if (rowIndex % 2 == 0)

            {

                brush = Brushes.Pink;

                return brush;

            }

            else

            {

                if (MainWindow.colIndex == -1 && MainWindow.rowIdex == -1)

                {

                    brush = Brushes.Pink;

                }

                else

                    brush = Brushes.Red;

            }

 

            return brush;

 

 

        }

 

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            throw new NotImplementedException();

        }

 

    }

 

Regards,

Sabaridass R.

 

Reply
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon