This is a migrated thread and some comments may be shown as answers.

Filter Funnel Icon Colour

3 Answers 91 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 20 Apr 2012, 04:39 PM
Hi,

How do I alter the colour of the funel icon when the column has been filtered. I am using the Metro  theme set in ther MainPage like thus:

Telerik.Windows.Controls.

 

StyleManager.ApplicationTheme = new MetroTheme();

 


I can use code behind but my project is not blendable.

Andy

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 25 Apr 2012, 04:21 PM
Hi,

What did you mean by mentioning that your project is "not Blendable"? If it is needed, we can extract this template and modify it for you. Basically, you can also accomplish this at runtime by finding these paths in the visual tree and setting their Fill property, but I do not believe that this is a good solution. The button elemnt is named "PART_DropDownButton" and its Content consists of these two paths.

Kind regards,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Andy
Top achievements
Rank 1
answered on 08 May 2012, 02:11 PM
Whay I mean by nor blendable is that we are not using Blend for design and certain elements of the code behind mean that Blend wil nnot open the page unles I hack around with it,

Running the following code brings back null. Can you adise?

RadGrid.FindName(

 

"PART_DropDownButton")

Andy Newland

 

0
Andy
Top achievements
Rank 1
answered on 08 May 2012, 04:57 PM
private void OverrideFilterIconOnColour()
{
    this.UpdateLayout(); // this is needed if this function is called early in the lifecycle
    // Get the header cells and iterate
    IEnumerable<GridViewHeaderCell> headerCells = this.radGrid.ChildrenOfType<GridViewHeaderCell>();
    foreach (GridViewHeaderCell headerCell in headerCells)
    {
        try
        {
            // Traverse the elements that make up the header cell
            Button button = headerCell.ChildrenOfType<Button>().First();
            Border border = (Border)button.Content;
            Grid grid = (Grid)border.Child;
            // The grid contains 2 shapes, the first displays when the filter is off and the second when the filer is on
            UIElementCollection UIElementCol = grid.Children;
            // Get the filter off shape and change the colour
            System.Windows.Shapes.Path filterOffImage = (System.Windows.Shapes.Path)UIElementCol.ElementAt(1);
            filterOffImage.Fill = new SolidColorBrush(Color.FromArgb(255, 229, 16, 0));
        }
        catch
        {
            // Don't do anything if this fails, it's not that important
        }
    }
}

Something like this does the trick via code. Obviously it will fall apart if you chnage the header row structure at any time.....

Andy Newland
Tags
GridView
Asked by
Andy
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Andy
Top achievements
Rank 1
Share this question
or