1 Attachment(s)
VB.net 2010 - WPF Datagrid Cell Background Style Issue
So, I am trying to setup a datatrigger for a datagridcell in WPF that shows a red square when the cell contains the word "red". It works but the problem is I am modifying the background and when the row is selected it shows a white box around the square. I want to get rid of the white box and I have been looking for another way of going about what I want but can't figure it out. Below is the code and an example image.
Code:
<Style x:Key="dgJobsPriority" TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Priority}" Value="Red">
<Setter Property="Background">
<Setter.Value>
<DrawingBrush Stretch="None">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Red">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,16,16" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
<Setter Property="Foreground" Value="#00000000"/>
</Style>
Attachment 100547
Re: VB.net 2010 - WPF Datagrid Cell Background Style Issue
Of course I figure it out not long after I post this ... so annoying when that happens. If anyone could provide some insight if this is an "acceptable" way of doing this or if there is a "better" way I would appreciate the input. WPF seems so powerful but also so confusing for just being markup at times.
Code:
<Style x:Key="dgJobsPriority" TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Priority}" Value="Red">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<Canvas>
<Rectangle Width="16" Height="16" Fill="Red" Canvas.Left="3" Canvas.Top="3" />
</Canvas>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
Re: VB.net 2010 - WPF Datagrid Cell Background Style Issue
Is it not a margin or a padding?