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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:15:39+00:00 2026-05-12T22:15:39+00:00

I use a datatemplate to visualize some items in a ComboBox, the ItemsSource is

  • 0

I use a datatemplate to visualize some items in a ComboBox,
the ItemsSource is bound to an ObservableCollection.
To keep it simple, let’s say I put persons into the ObservableCollection:

public class Person {
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

My DataTemplate looks like this:

<DataTemplate TargetType="{x:Type Person}">
  <StackPanel Orientation="Horizontal">
    <TextSearch.Text>
      <MultiBinding StringFormat="{} {0} {1}">
        <Binding Path="FirstName"/>
        <Binding Path="LastName"/>
      </MultiBinding>
    </TextSearch.Text>
    <TextBlock Text="{Binding FirstName}" Margin="2,0" />
    <TextBlock Text="{Binding LastName}"/>
  </StackPanel>
</DataTemplate>

Now I want to enable autocompletion for full names in the ComboBox without introducing a third property on my person class. Hence I do not want to use TextSearch.TextPath Property on the ComboBox, but instead I would like to bind the TextSearch.Text-Property of each ComboBoxItem in the DataTemplate.
Unfortunately, when I do this (which works with a MultiBinding and StringFormat, tested with Snoop), the bound value is registered for my StackPanel only, but using Snoop (great tool) I found that this stackpanel serves just as content for some further ComboBoxItemTemplate, which puts another border etc. and finally a ComboBoxItem-tag around my outer StackPanel. Therefore, the TextSearch.Text-setting is not effective, because it must be set in the created ComboBoxItem, and not somewhere within.

Question now: How can I propagate this TextSearch.Text-Property from my DataTemplate to the surrounding ComboBoxItem using XAML-Styles and -Control-Templates only?
The solution may modify the default-ControlTemplates of ComboBox and ComboBoxItem and my custom (Item-)DataTemplate, but not use any Code-Behind, or at least not too much. Maybe an attached behaviour would be ok, too. But I’m almost sure there must be a way to make it work without, TemplateBinding or RelativeSource-stuff…
And of course the solution must make my keyboard-selection and textcompletion work, s.th. when the list contains Hans Josef and Hans Peter, then entering ‘Hans ‘ should autosuggest Hans Josef, whereas entering ‘Hans P’ quickly enough should autosuggest Hans Peter.

Any solutions?

  • 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-12T22:15:39+00:00Added an answer on May 12, 2026 at 10:15 pm

    That stuff surrounding your panel is the default container. You need to apply the TextSearch.Text property to the container. You should be able to do this by setting the property via the ItemContainerStyle like so:

    <ComboBox.ItemContainerStyle>
        <Style TargetType="{x:Type ComboBoxItem}">
            <Setter Property="TextSearch.Text">
                <Setter.Value>
                    <MultiBinding StringFormat="{} {0} {1}">
                        <Binding Path="FirstName"/>
                        <Binding Path="LastName"/>
                    </MultiBinding>
                </Setter.Value>
            </Setter>
        </Style>
    </ComboBox.ItemContainerStyle>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use what's below as a DataTemplate for items bound in a
People use frequently something like: <ListBox ItemsSource={Binding ElementName=thisControl, Path=ListIndexes}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Label Content={Binding
I use a stream reader to import some data and at the moment I
I generate ListBox menu from XML. I use datatemplate to style the behavior of
I have a DataTemplate that I use to display details from a class in
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
We use a data acquisition card to take readings from a device that increases
I use Firebug and the Mozilla JS console heavily, but every now and then

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.