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

overriding the Filtering Control with a Style Manager

2 Answers 212 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Feb 2011, 05:25 PM
I'm currently trying to use the GridView control with the Expression Dark Skin. I'm styling the whole control using the style manager. This works completely fine, however I've had to override the the filtering control to set a default option using the same technique as detailed in this thread:

http://www.telerik.com/community/forums/wpf/gridview/hide-and-filtering-options.aspx

When I do this the style of the filter control reverts back to the default Office Black theme. I thought about trying to set the style from code behind when I'm overriding the filter control, but I've no idea where to begin to do this. I've attached the relevant code below. Does anyone have any idea what the solution would be?

public class CustomFilteringControl : Telerik.Windows.Controls.GridView.FilteringControl
    {
        public override void Prepare(GridViewBoundColumnBase column)
        {        
            base.Prepare(column);
 
            if (column.DataType == typeof(string)) // Set contains as default only for string data type of the gridview column
            {
                FilteringViewModel vm = this.DataContext as FilteringViewModel;
 
                if (vm != null)
                {
                    if (!vm.Filter1.IsActive)
                    {
                        vm.Filter1.Operator = FilterOperator.Contains;
                    }
 
                    if (!vm.Filter2.IsActive)
                    {
                        vm.Filter2.Operator = FilterOperator.Contains;
                    }
                }
            }
        }
 
    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 24 Feb 2011, 07:31 PM
Hi Mark,

 I have set an implicit style, targeting your CustomFilteringControl, which modifies its template. Please, pay attention that I have set the Application theme to ExpressionDark, in order to theme the controls that are used in the teplate defined. Refer to the attached project, please.

Regards,
Ivan Ivanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Mark
Top achievements
Rank 1
answered on 28 Feb 2011, 02:37 PM
Thanks for your sample solution, it worked a treat. I think my problem was that I hadn't included a reference to the class where I use the custom control. Once again, thanks for your help!
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or