Hi Folks,
I'm styling my XamDataGrid. For some reason active cell has gradient instead of solid brush with a specific background color. Can you help me get active cell background color set to a specific hex?
This is my code: which obviously doesn't work...
<Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="BackgroundHover" Value="#F7914B"/> <Setter Property="BorderHoverBrush" Value="#F7914B"/> <Setter Property="BackgroundSelected" Value="#EC660A"/> <Setter Property="BackgroundActive" Value="#EC660A"/> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="BorderThickness" Value="0.5"/> <Setter Property="BackgroundAlternate" Value="#bfbfbf"/> </Style> <Style TargetType="{x:Type igDP:CellPresenter}"> <Style.Triggers> <Trigger Property="IsActive" Value="True"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="#F7914B"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> <Style x:Key="{x:Type igDP:FilterCellValuePresenter}" TargetType="{x:Type igDP:FilterCellValuePresenter}"> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="BorderThickness" Value="0.5"/> <Style.Triggers> <Trigger Property="HasActiveFilters" Value="true"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="#EC660A"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style>
Glad to hear that worked. Let me know how things go moving forward.
OK it started working when i moved <style? blocks from USerControl.Resources to XamDataGrid.Resources.
Thanks for help
Nope sorry doesn't work. I think this has something to do with default theme which uses gradient for celected cell background brush. See pic below.
My code:
<UserControl.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="BackgroundHover" Value="#F7914B"/> <Setter Property="BorderHoverBrush" Value="#F7914B"/> <Setter Property="BackgroundSelected" Value="#EC660A"/> <Setter Property="BackgroundActive" Value="#EC660A"/> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="BorderThickness" Value="0.5"/> <Setter Property="BackgroundAlternate" Value="#dcdcdc"/> <Setter Property="CornerRadius" Value="0"/> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <Trigger Property="IsActive" Value="True"> <Setter Property="BackgroundActive"> <Setter.Value> <SolidColorBrush Color="#EC660A"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> <Style x:Key="{x:Type igDP:FilterCellValuePresenter}" TargetType="{x:Type igDP:FilterCellValuePresenter}"> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="BorderThickness" Value="0.5"/> <Style.Triggers> <Trigger Property="HasActiveFilters" Value="true"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="#EC660A"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </UserControl.Resources> <igDP:XamDataGrid Grid.Row="1" Name="_componentsTable" RecordFilterDropDownPopulating="_componentsTable_RecordFilterDropDownPopulating" DataSource="{Binding Components}" SelectedDataItem="{Binding Path=SelectedComponent, Mode=TwoWay}" SelectedDataItemsScope="RecordsOnly" GroupByAreaLocation="None" BorderBrush="#688caf" BorderThickness="1"> <igDP:XamDataGrid.Resources> <ContextMenu x:Key="ContextMenu" DataContext="{Binding PlacementTarget,RelativeSource={RelativeSource self}}"> <MenuItem Header="Copy" Command="{Binding Path=DataContext.CopyDrillStringComponentCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}"/> <MenuItem Header="Paste" Command="{Binding Path=DataContext.PasteDrillStringComponentCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}"/> </ContextMenu> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ContextMenu" Value="{StaticResource ContextMenu}"/> <Setter Property="BorderThickness" Value="0.5"/> <Setter Property="BorderBrush" Value="Black"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.InputBindings> <KeyBinding Command="{Binding Path=DataContext.DeleteSelectedComponentCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" Key="Delete"/> <KeyBinding Command="{Binding Path=DataContext.DeleteSelectedComponentCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" Key="Back"/> </igDP:XamDataGrid.InputBindings> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowRecordFiltering="True" AllowGroupBy="False" FilterOperatorDropDownItems="None" IsAutoEditModeEnabled="True" CellClickAction="SelectCell"/> </igDP:XamDataGrid.FieldSettings> and so on
Hello Michal,
Thank you for following up. I just tested this out on my end (see below) and as long as you have CellClickAction to SelectCell it should work otherwise if you are selecting rows then this will get overriden by the DataRecordCellArea.
<Grid> <Grid.Resources> <Style TargetType="{x:Type ig:CellValuePresenter}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="BackgroundActive" Value="Red">
</Setter> </Trigger> </Style.Triggers>
</Style> </Grid.Resources> <ig:XamDataGrid DataSource="{Binding Data}"> <ig:XamDataGrid.FieldSettings> <ig:FieldSettings CellClickAction="SelectCell" /> </ig:XamDataGrid.FieldSettings> </ig:XamDataGrid></Grid>
XDGModified.zip
Nope. Same result.
I tried "IsSelected" and "IsActive" as trigger properties. No luck.
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="BackgroundActive"> <Setter.Value> <SolidColorBrush Color="#EC660A"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style>