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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:54:11+00:00 2026-05-14T18:54:11+00:00

I’m writing a WPF User Control for my application, wrapping a ListBox and a

  • 0

I’m writing a WPF User Control for my application, wrapping a ListBox and a few other items.

The ListBox has a new ItemTemplate that presents four pieces of information for each item in my list. I can hard code each of the four bindings to specific properties on my list items and they display fine.

However, I want my UserControl to be a bit more flexible.

On ListBox and ComboBox there is a property DisplayMemberPath (inherited from ItemsControl) that seems to “inject” the appropriate property binding into the standard ItemTemplate.

How do I achieve the same result with my user control?

I’d like to set up four new properties to allow configuration of the information displayed:

public string LabelDisplayPath { get; set; } 
public string MetricDisplayPath { get; set; }
public string TitleDisplayPath { get; set; }
public string SubtitleDisplayPath { get; set; }

Reviewing ItemsControl.DisplayMemberPath with Reflector seems to go down the rabbit hole, I haven’t been able to fathom how it works.

Also, if I’m completely off course – and there’s another, more “WPF” technique that I should be using instead, please point me in that direction.

Update

Here’s a clarification of what I’m trying to achieve.

The ListBox within my user control displays four pieces of information per item: Label, Title, Subtitle and Metric

In one place, I want to use this User control to display a list of issues. Each issue looks like this:

public class Issue {
    public string Code { get; set; }
    public string Description { get; set; }
    public string Priority { get; set; }
    public string Reporter { get; set; }
}

When displaying issues, I want to use the following mappings:

Code --> Label
Description --> Title
Reporter --> Subtitle
Priority --> Metric

Elsewhere in the same application, I have a list of Posts that I want to display using the same UserControl. Each Post looks like this:

public class Post {
    public DateTime PostedOn { get; set; }
    public string Title { get; set; }
    public string Teaser { get; set; }
    public int CommentCount { get; set; }
}

When displaying posts, I want to use the following mappings:

PostedOn --> Label
Title --> Title
Teaser --> Subtitle
CommentCount --> Metric

Given that Issues and Posts are quite different abstractions, I don’t want to force them to have the same properties, just to allow the UserControl to be used unchanged. Instead, I want to introduce a little configurability so that I can reuse my UserControl in both sites cleanly.

  • 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-14T18:54:11+00:00Added an answer on May 14, 2026 at 6:54 pm

    I’ve found the solution to my problem – it’s a bit more complicated than I’d like …

    On any ItemsControl, when you set the DisplayMemberPath property, an instance of the internal class DisplayMemberTemplateSelector is assigned to the ItemTemplateSelector. In effect, this class generates a custom DataTemplate with an appropriate binding to suit the current configuration of DisplayMemberPath. A new instance of this class is created and used every time that DisplayMemberPath is changed.

    To replicate this on my own Usercontrol, instead of modifying my existing data template on the fly as I had originally intended, I need to create my own template selector helper class and mimic the same approach as ItemsControl.

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

Sidebar

Related Questions

No related questions found

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.