Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7059345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:13:16+00:00 2026-05-28T04:13:16+00:00

I am trying to add some styles in some DataGrid s I have. I

  • 0

I am trying to add some styles in some DataGrids I have.

I am currently working on an application designed to show huge amounts of financial data (matrices of numbers) with many visual tools to detect good data, wrong data… and correct them if needed, by comparing them to a target value

For now, I have a color-code which is basically:

  • White background: the current value is fine
  • Red background: the current value is under the target value!
  • Green background: the current value is above the target value!

And I play with transparency to set the background clear if kinda close to the good value, strong otherwise.

Now I’d like to add another visual tool: some sort of visual pattern, to notify the user that this value, while being correct or wrong, presents a potential risk (as I said earlier it is financial data, so it’s mostly measuring money-loss risks).

The current application, programmed in VBA, uses a trick that adds an empty comment to a cell so a small red triangle will appear on corner.

I’d like to find a way to add it to my XAML style, the nicest thing I came up with was to add a visual pattern.

Here is an example on what I’m trying to achieve:

Grid example

On the left column, you can see “normal display”.
On the right one, I added the “danger-styles”, which are supposed to mean “warning, there is something wrong with this value”.
The first line shows the old way of doing it on Excel: with a fake comment, which adds a red triangle on the top-right corner.

Would you have any idea on how to achieve that? Would an Adorner do the trick?

By the way, the grid is editable so I obviously don’t want to loose the editable aspect, so that makes me doubt of a possible Adorner…

Here is the current XAML Style, which is applied as a CellStyle:

<Style x:Key="DynamicCellStyle" TargetType="{x:Type DataGridCell}">
    <Style.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Background" Value="#FF316AC5" />
        </Trigger>
        <Trigger Property="IsSelected" Value="False">
            <Setter Property="Background">
                <Setter.Value>
                    <MultiBinding Converter="{StaticResource CellToColorConverter}">
                        <!-- Some bindings for the converter to compute the actual color -->
                    </MultiBinding>
                </Setter.Value>
            </Setter>
        </Trigger>
    </Style.Triggers>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridCell}">
                <Grid Background="{TemplateBinding Background}">
                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>

    </Setter>

Any idea here?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:13:17+00:00Added an answer on May 28, 2026 at 4:13 am

    Okay, I found a very proper way to do it, using a DrawingBrush

                                                <DrawingBrush TileMode="Tile"
                                                          ViewportUnits="RelativeToBoundingBox"
                                                          Viewport="0,0,0.20,1">
                                                    <DrawingBrush.Drawing>
                                                        <DrawingGroup>
                                                            <GeometryDrawing>
                                                                <GeometryDrawing.Pen>
                                                                    <Pen Brush="Red" Thickness="0.83"/>
                                                                </GeometryDrawing.Pen>
                                                                <GeometryDrawing.Geometry>
                                                                    <RectangleGeometry Rect="0.3,0.4,0.3,0.21" RadiusX="0" RadiusY="0"/>
                                                                </GeometryDrawing.Geometry>
                                                            </GeometryDrawing>
                                                            <GeometryDrawing>
                                                                <GeometryDrawing.Pen>
                                                                    <Pen Brush="Black" Thickness="0.05"/>
                                                                </GeometryDrawing.Pen>
                                                                <GeometryDrawing.Geometry>
                                                                    <LineGeometry StartPoint="0,1" EndPoint="1,0" />
                                                                </GeometryDrawing.Geometry>
                                                            </GeometryDrawing>
                                                        </DrawingGroup>
                                                    </DrawingBrush.Drawing>
                                                </DrawingBrush>
    

    Basically you’d draw a red Rectangle (you can change the color of course) which will fill the cell, so act as a background, and also draw above 5 diagonal lines.
    You can change the numer online by switching the x number here: Viewport="0,0,x,1". In my case it is 0.20 which means 20% of the total surface, eg the Geometry will be drawn five times, each one occupying 20% of the available width.

    Use this brush as a background for any DataGridCell , and you’ll get the following result:

    DataGrid templates

    Which is almost exactly what I wanted (and renders a bit better than the GradientBrush idea from dex3703 )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add some accessibility for screen readers into a Flash application, and
I'm trying to add some styles into a page using javascript var style =
I am trying to add some styling to a magento extension.For this I have
I have this HTML file with some CSS styles, now I am trying to
Im currently trying to add some Style to my Hyperlinkbutton, but cannot get it
i have this carousel from here and i am trying to add some css3
Im trying to add some short file names to a Wise installer to fix
I am trying to add some error detection to a script that is used
I was trying to add some non-production test code by creating a 3rd partial
I am trying to add some WebAPI support to my asp.net 4 RC site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.