Hello Johannes,
Creating the style in the Xaml :
<UserControl.Resources>
<Style TargetType="c1:ColumnFilterEditor" x:Key="ColumnFilterEditorStyle">
<Setter Property="Background" Value="Green" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="5" />
</Style>
</UserControl.Resources>
and then assigning the same in the code behind within the EditorOpened event works correctly :
private void C1FlexGridFilter_EditorOpened_1(object sender, EventArgs e)
{
C1FlexGridFilter cfe = sender as C1FlexGridFilter;
if (cfe != null && cfe.Editor != null)
{
cfe.Editor.ClearValue(ColumnFilterEditor.BackgroundProperty);
cfe.Editor.ClearValue(ColumnFilterEditor.BorderBrushProperty);
cfe.Editor.ClearValue(ColumnFilterEditor.BorderThicknessProperty);
cfe.Editor.Style = ((Style)this.Resources["ColumnFilterEditorStyle"]);
}
}
But if the style to the ColumnFilterEditor is applied in Xaml only, then the same does not works and results in an NullReferenceException :
<c1:C1FlexGridFilterService.FlexGridFilter>
<c1:C1FlexGridFilter EditorOpened="C1FlexGridFilter_EditorOpened_1">
<c1:C1FlexGridFilter.Editor>
<c1:ColumnFilterEditor Style="{StaticResource ColumnFilterEditorStyle}"/>
</c1:C1FlexGridFilter.Editor>
</c1:C1FlexGridFilter>
</c1:C1FlexGridFilterService.FlexGridFilter>
Reason being the FilterDropDown is not rendered till the time it is opened and the EditorOpened event is raised. Upon styling the FilterDropDown in Xaml it results in an NullReferenceException because the Filter is not yet created.
Let me know if I missed something here.
Regards,
Reema