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
1500
The alternate cell style cannot set in the XamGrid
posted

Hi,

I want to change Cells's background to different color.

but I find that when I set the style for Cells, these cells in the alternate row cannot change color as follow chart:

 The second cell should be blue, the forth cell should be yellow. But these are also default color.

I change the style in the CellControlAttached event as follow:

private void m_UserManagementGrid_CellControlAttached(object sender, CellControlAttachedEventArgs e)
        {
            if (e.Cell.Column.Key == "AccountName" && e.Cell.Value != null)
            {
                if (e.Cell.Value.ToString() == "User1" || e.Cell.Value.ToString() == "User2")
                {
                    Style style = this.Resources["LastMatchStyle"] as Style;//Set Blue Color
                    e.Cell.Style = style;
                }
                else
                {
                    Style style = this.Resources["FirstMatchStyle"] as Style;//Set Yellow Color
                    e.Cell.Style = style;
                }
            }
        }

Could you tell me why the setting cannot work in the alternate row ?

And is there any better method to achieve this function?