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 912317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:21:35+00:00 2026-05-15T17:21:35+00:00

I have a requirement to generate a report in WPF which is simply a

  • 0

I have a requirement to generate a “report” in WPF which is simply a grid.

However, the columns and the styling rules (e.g. “Red if value below zero”) for this grid are unknown at compile time.

There are hundreds of questions like this and I must have read over half of them but I cannot find a solution to this requirement which would be trivial in WinForms.

I have managed to style an entire row by setting the ItemContainerStyle of the ListView, but I couldn’t manage to get this to focus on a single cell.

As such I’m now trying the CellTemplate approach but this throws an error ({"Child with Name '{x:Type ListViewItem}' not found in VisualTree."}) and of course when I use a DisplayMemberBinding the CellTemplate isn’t even called at all.

My converter when it gets passed the value is getting the entire row, not just the cell’s value, so perhaps this is useful information.

 GridView viewLayout = new GridView();
 for (int i=0; i<columns.Length; i++)
 {
    ColumnDisplaySettings col = columns[i];
    var g = new GridViewColumn() 
    { 
        Width = col.Width, 
        //DisplayMemberBinding = "[" + i + "]" /* Have to omit this for CellTemplate */
    };

    if (i == 0)
    {
       g.CellTemplate = new DataTemplate();
       var t = new DataTrigger();
       t.Binding = new Binding("[0]");
       t.Value = "0";
       var b = new Binding() { Converter = new MyBkColorConverter() };
       t.Setters.Add(new Setter(Control.BackgroundProperty, b,
          "{x:Type ListViewItem}")); /* Error here */
       g.CellTemplate.Triggers.Add(t);
    }

     viewLayout.Columns.Add(g);
 }
 lv.View = viewLayout;

I’ve encountered DataTemplateSelectors in my searches, so if a useful reference exists on using these without any known XAML then I’d appreciate that too.

Thanks for any help you can provide.

  • 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-15T17:21:35+00:00Added an answer on May 15, 2026 at 5:21 pm

    The error is happening because “{x:Type ListViewItem}” is a string. The {x:..} notation is a XAML markup extension, but you’re not using XAML. To refer to the list ListViewItem in code, use typeof(ListViewItem).

    Oh also, you’re trying to set the Background property to a type, ListViewItem, which makes little sense.. let me re-read and update this answer..

    Update: you don’t need the third parameter to the Setter constructor.

    Hope that helps!

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

Sidebar

Related Questions

I have a requirement in which i need to process few data to generate
I have a requirement to put together an application which will generate a web
I have a requirement where I need to generate a report about current software
I have the following requirement: Based on some user input, I need to generate
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I currently have the following code to generate a sales report over the last
Suppose I'm given the requirement to generate a few pages that have tables on
I have the requirement to create a page which contains a graph at the
I have a requirement to dynamically generate and compress large batches of PDF files.

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.