public override void OnApplyTemplate() { base.OnApplyTemplate(); // ensure that the custom inactive style is applied if (FilterButtonInactiveStyle != null) { List <FrameworkElement> columnHeaders = UIHelpers.FindElementsOfType(this, typeof(GridViewColumnHeader)); foreach (FrameworkElement columnHeader in columnHeaders) { Button button = (Button)UIHelpers.FindElementOfType(columnHeader, typeof(Button)); if (button != null) { button.Style = FilterButtonInactiveStyle; } } } }