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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:38:54+00:00 2026-05-12T13:38:54+00:00

I have a combo box in which I set up an ItemTemplate that looks

  • 0

I have a combo box in which I set up an ItemTemplate that looks something like this:

<ComboBox.ItemTemplate>
  <DataTemplate>
    <StackPanel Orientation="Horizontal">
      <TextBlock Text="{Binding Piece.NoPiece}" Width="50" />
      <TextBlock Text="{Binding Piece.Description}" Width="170" />
      <TextBlock Text="{Binding Piece.Categorie.NomCategorie}" />
    </StackPanel>
  </DataTemplate>
</ComboBox.ItemTemplate>

As you can see, I got three columns that let the user see different piece of information. However, I would like the selected item in the combo to display only the second column. In other word, is there a way to have an ItemTemplate that displays items in a different manner when you scroll down versus when it’s closed and you only see the selection?

  • 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-12T13:38:54+00:00Added an answer on May 12, 2026 at 1:38 pm

    You can do it with triggers:

    <ComboBox.ItemTemplate>
      <DataTemplate>
        <StackPanel Orientation="Horizontal">
          <TextBlock Text="{Binding Piece.NoPiece}" Width="50" x:Name="Column1" />
          <TextBlock Text="{Binding Piece.Description}" Width="170" />
          <TextBlock Text="{Binding Piece.Categorie.NomCategorie}" x:Name="Column3" />
        </StackPanel>
        <DataTemplate.Triggers>
          <!-- This trigger fires for the selected item in the drop-down list -->
          <DataTrigger Binding="{Binding 
                           RelativeSource={RelativeSource Mode=FindAncestor, 
                                                          AncestorType=ComboBoxItem},
                           Path=IsSelected}" 
            Value="True">
            <Setter TargetName="Column1" Property="Visibility" Value="Hidden" />
            <Setter TargetName="Column3" Property="Visibility" Value="Hidden" />
          </DataTrigger>
    
          <!-- This trigger fires for the selected item (ie the one that's
               visible when the popup is closed -->
          <DataTrigger Binding="{Binding 
                           RelativeSource={RelativeSource Mode=FindAncestor, 
                                                          AncestorType=ComboBoxItem}}"
                       Value="{x:Null}">
            <Setter TargetName="Column1" Property="Visibility" Value="Hidden" />
            <Setter TargetName="Column3" Property="Visibility" Value="Hidden" />
          </DataTrigger>
        </DataTemplate.Triggers>
      </DataTemplate>
    </ComboBox.ItemTemplate>
    

    EDIT

    I’ve updated the XAML to show how to apply the alternative formatting to the selected item when the popup is collapsed (I’m not sure what that area is called.)

    The trick is that items in the drop-down area are contained within ComboBoxItem objects in the logical tree. The RelativeSource binding looks for an object of that type as an ancestor.

    • If it finds it, it assumes that the item is in the tree (and checks whether it’s selected)
    • If it’s not found (null) then it assumes the item is in the combo box area rather than the popup

    This would fall apart if you, somehow, had a combo box within the item template of another combo box. I don’t think I’d like to use that UI though!

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

Sidebar

Related Questions

I have this form, in which i need to populate a combo box with
I have a combo box that I bind to an observable collection, which gets
I have a combo box in which I have to display the dates from
I have a form which has a Combo Box Control. I have selected the
I have a maximized form which has Combo-Box control (docked in top-right) with 500px
I have a DataTemplate that will be a templated ListBoxItem, this DataTemplate has a
I would like to have a ComboBox control on a form which will be
I'm attempting to have a combo-box display a pre-defined set of values - in
I have a combo box CBS_DROPDOWNLIST control filled with numeric values. I'd like for
I have a combo box where I am displaying some entries like: Equals Not

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.