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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:01:11+00:00 2026-06-08T07:01:11+00:00

I have a custom template for my WPF windows ComboBoxes, which display items that

  • 0

I have a custom template for my WPF windows ComboBoxes, which display items that inherit from ComboBoxItem that also have an Image property (so that my items can display both text and an image). Both the text and image display as expected in the ComboBox’s popup menu for any given item, but I haven’t been able to display an image in the currently selected item.

The ContentPresenter within the ComboBox template that displays the currently selected item has its Content property properly bound to {TemplateBinding SelectionBoxItem}, and its ContentTemplate is bound to the following static resource:

    <DataTemplate x:Key="SelectionBoxItemTemplateTextAndImage" DataType="{x:Type SB:SBComboBoxItem}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Image Source="{Binding Image}"/>
            <TextBlock Grid.Column="1" Text="{Binding}"/>
        </Grid>
    </DataTemplate>

SBComboBoxItem is the custom control that inherits from ComboBox and contains an “Image” property properly registered as a DependencyProperty.

I have attempted alternative implementations of that DataTemplate, including using:

{Binding Path=Image, RelativeSource={RelativeSource TemplatedParent}}

as the image’s source. That didn’t work, even though the text still displays when i set the TextBlock’s Text property to:

{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}

I’ve played around and found numerous implementations that display the text, but the equivalents never work for the image. I don’t understand why this doesn’t work, as setting up the popup to display both images and text was a breeze.

Edit: Here’s the added functionality to ComboBoxItem to handle the image, in case there’s something I did wrong there:

    public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(Image), typeof(SBComboBoxItem));
    public Image Image { get { return (Image)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } }

And here is where I have a ComboBox with the items added:

<ComboBox SelectedIndex="1">
    <SB:SBComboBoxItem Content="Text">
        <SB:SBComboBoxItem.Image>
            <Image Source="..\Images\Table.png"/>
        </SB:SBComboBoxItem.Image>
    </SB:SBComboBoxItem>
    <SB:SBComboBoxItem Content="MoreText">
        <SB:SBComboBoxItem.Image>
            <Image Source="..\Images\Euclidian.png"/>
        </SB:SBComboBoxItem.Image>
    </SB:SBComboBoxItem>
</ComboBox>
  • 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-08T07:01:13+00:00Added an answer on June 8, 2026 at 7:01 am

    Despite the fact that I was using a DataTemplate to expose the underlying type of my selected combobox item through DataTemplate’s DataType property, the SelectionBoxItem property of my ComboBox was apparently returning something that could not be cast as my custom ComboBoxItem. I don’t know why this is, nor why it did not fire any runtime errors, but I found that by binding to ComboBox’s SelectedItem property instead of SelectionBoxItem in the ContentPresenter allowed me to access user defined properties.

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

Sidebar

Related Questions

I have a wpf cusotm control derived from combobox System.Windows.Controls.ComboBox the control template is
I have custom Rythm template tag (sayHi.html) which I want to call from parent
I have a custom magento template which im trying to tweak and just have
I have a custom iterator template class that wraps up a std::list iterator. In
I have a template that displays the titles of a custom post type. I
I'm building a custom WPF control that derives from TabControl. In the ControlTemplate, I'm
I'd like to create a custom validator template for my WPF app. I have
I have a DataGrid (WPF Toolkit) with a custom combobox like edit template of
I have a WPF DataGrid (.NET 4) with custom template columns and header styles
I have created a custom TaskButton control that takes an image and text. The

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.