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

  • SEARCH
  • Home
  • 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 9253729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:17:32+00:00 2026-06-18T11:17:32+00:00

I have a user control that inherits from the WPF DataGrid control and to

  • 0

I have a user control that inherits from the WPF DataGrid control and to which I pass different List of objects and, so, the columns of the grid depend (i.e. are automatically generated) on the class of object that I send through.

<userc:cfDataGrid x:Name="grdResults" 
    FontStyle="Normal" 
    FontFamily="Microsoft Sans Serif" 
    FontSize="14" 
    RowHeight="30"  

    AutoGenerateColumns="True" 
    Margin="12" 
    AlternatingRowBackground="Gainsboro"  
    AlternationCount="2" 

    ItemsSource="{Binding Results}" 
    IsReadOnly="True" 
    HeaderNames="{Binding Headers}" >
</userc:cfDataGrid> 

Now, I’d like to also pass through a list of objects that have an attribute of SolidColorBrush data type and be able to use this value to set the background colour of the cell rather than display the actual value.

I have not done much work with styles etc and so I wanted to ask if anyone could give me some pointers on how to trap a column with a SolidColorBrush datatype – and perform the action described above – without depending on the name of the column?

Any pointers would be greatly appreciated!

CC

  • 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-06-18T11:17:33+00:00Added an answer on June 18, 2026 at 11:17 am

    I would use a DataTrigger that used a Converter to check if the object was a SolidColorBrush, and if so set the background color

    Something like this:

    <DataGrid.Resources>
        <Style TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <!-- DataContext will be object for entire data row -->
                <DataTrigger Binding="{Binding MyBrushColorProperty, Converter={StaticResource IsSolidBrushColor}}" Value="True">
                    <Setter Property="Background" Value="{Binding MyBrushColorProperty}" />
                    <Setter Property="Content" Value="" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </DataGrid.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that inherits from the ListBox class and displays a
I have an user control which has a treeview. This user control inherits from
I have a user control that inherits from UserControl. It's a button so I'm
I have a custom control that inherits from UserControl , and I can't get
I have a custom control Workspace that inherits from Control and within it is
I have a custom control that inherits from TreeView . In this CustomTreeView ,
I have created a custom server control that inherits from CompositeControl. In the CreateChildControls
I have user control that inherits a base control class and these user controls
I have a custom Grid view object that inherits from the base System.Web.UI.WebControls.GridView. The
I have a class ShipmentsCollection that inherits ObservableCollection which contains shipment objects (entities). This

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.