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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:17:19+00:00 2026-05-22T01:17:19+00:00

I have the current Combo Box XAML: <ComboBox Height=23 HorizontalAlignment=Left ItemsSource={Binding ElementName=showDomainDataSource, Path=Data} Margin=583,8,0,0

  • 0

I have the current Combo Box XAML:

        <ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=showDomainDataSource, Path=Data}" Margin="583,8,0,0" x:Name="showsComboBox" VerticalAlignment="Top" Width="233" SelectionChanged="showsComboBox_SelectionChanged" IsSynchronizedWithCurrentItem="False">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=showName, Converter={StaticResource distinctConverter}}" x:Name="showsComboxshowName" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

And I have the class – DistinctConverter:

public class DistinctConverter : IValueConverter
{
    public object Convert(
        object value, Type targetType, object parameter, CultureInfo culture)
    {
        var values = value as IEnumerable;
        if (values == null)
            return null;
        return values.Cast<object>().Distinct();
    }

    public object ConvertBack(
        object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}

I have added the following to my resources:

<convert:DistinctConverter x:Key="distinctConverter" />

The problem is, I’m getting the error in my combo box:

enter image description here

Can anyone help me with whatever I’m doing wrong here.

  • 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-22T01:17:20+00:00Added an answer on May 22, 2026 at 1:17 am

    The problem is that the showName property in your model is returning a collection which you want to bind to the Text property of a TextBox which is a string. Then you have a converter that takes a collection as input, runs a LINQ query on it, which returns another collection. That value, the whole collection, is being converted by the binding to a string using ToString and being displayed as a single entry in your combo box. And then that process is repeated for each item in the combo box.

    Without knowing exactly what you are trying to accomplish, it’s hard to suggest exactly how to fix this. For example, if showName is equal to:

    string[] { "Bill", "Bill", "Mike", "Ted" };
    

    Would you like this to appear in the combo box row?

    Bill Mike Ted

    If so, then you can use Aggregate after you use Distinct.

    But it sounds more likely that you want Bill, Mike and Ted to appear as separate items in the combo box. In that case you need to apply the converter to the ItemsSource for the ComboBox itself instead of the TextBox in the ItemTemplate.

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

Sidebar

Related Questions

I have this very simple Combobox in my XAML: <ComboBox Name=cmb1 Width=200 Height=23 ItemsSource={Binding}
I have a combobox, and based on the current selection, I would like dynamic
i use google map in my newest project ,and i have a combo box
We have a current application where user login credentials are stored in a SQL
I have a current system which is build as a Windows Application, and does
I have the current basic structure for each domain object that I need to
I have four flags Current = 0x1 Past = 0x2 Future = 0x4 All
I use bzr for websites. I have all my current ones set up so
My current problem is that I have a JFrame with a 2x2 GridLayout. And
In our current database development evironment we have automated build procceses check all 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.