Devid
Devid

Reputation: 2003

How to change FlagEnumEditor Color in Telerik WPF?

I am using WPF Telerik FlagEnumEditor in my column named Statistiken. FlagEnumEditor enables me to store any combination of the values that are defined in a enumerator.

The problem I am facing is that I can't change its color. I would like it to be transparent or white, just like all the other columns in my RadGridView are.

I have set the FlagEnumEditor BorderBrush and Background to Transparent and some other colors, but nothing happens. Am I missing something ? I don't understand why the color does not change here. How can I change the color of column Statistiken to be the same color as column Datentyp ?

columns

Stitistiken Column XAML Source Code:

<telerik:GridViewDataColumn x:Name="CheckComboBoxColumn"
                            Header="Statistiken"
                            IsReadOnly="True">
   <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
              <telerik:FlagEnumEditor BorderBrush="Transparent"
                                      Background="Transparent"
                                      Margin="-4,0,-2,0"
                                      Value="{Binding Aggregates, Mode=TwoWay}"
                                      EnumType="viewModels:Aggregates" />
        </DataTemplate>
   </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Enum Aggregates:

[Flags]
public enum Aggregates
{
    All = -1,
    None = 0,
    Avg = 1,
    Count = 2,
    Min = 4,
    Max = 8,
    Sum = 16
}

Datentyp Column XAML Source Code, but here I am using RadComboBox as I don't need to combine Enum values:

<telerik:GridViewDataColumn Header="Datentyp">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
             <telerik:RadComboBox BorderBrush="Transparent"
                                  Background="Transparent"
                                  Margin="-5,0,-2,0"
                                  ItemsSource="{Binding DataContext.ColumnTypes, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}},UpdateSourceTrigger=PropertyChanged}"
                                  SelectedItem="{Binding ColumnType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </DataTemplate>
             </telerik:GridViewDataColumn.CellTemplate>
    <telerik:GridViewDataColumn.CellEditTemplate>
         <DataTemplate>
              <telerik:RadComboBox BorderBrush="Transparent"
                                   Background="Transparent"
                                   Margin="0,0,0,0"
                                   ItemsSource="{Binding DataContext.ColumnTypes, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}},UpdateSourceTrigger=PropertyChanged}"
                                   SelectedItem="{Binding ColumnType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

ps. I am also open for solutions with the same effect as FlagEnumEditor.

Upvotes: 1

Views: 201

Answers (1)

mm8
mm8

Reputation: 169370

You could add an implicit RadDropDownButton style to the Resources property of the FlagEnumEditor to change its colours:

<telerik:FlagEnumEditor Margin="-4,0,-2,0"
                        BorderThickness="0"
                        Value="{Binding Aggregates, Mode=TwoWay}"
                        EnumType="viewModels:Aggregates">
    <telerik:FlagEnumEditor.Resources>
        <Style TargetType="telerik:RadDropDownButton" BasedOn="{StaticResource {x:Type telerik:RadDropDownButton}}">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
        </Style>
    </telerik:FlagEnumEditor.Resources>
</telerik:FlagEnumEditor>

Upvotes: 2

Related Questions