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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:33:29+00:00 2026-06-07T18:33:29+00:00

I have a WPF ComboBox that binds to a set of data. I do

  • 0

I have a WPF ComboBox that binds to a set of data. I do not have permissions to modify the control directly, nor can I change the data.

I’m returned 1 item in my ComboBox, but there are actually 2 rows; the blank row and my expected value. Both appear to have an index value of 0. I don’t want to see this blank row, just my expected data in the ComboBox auto-selected. I have looked through everyone’s related posts in here, but none of the solutions have worked for my case. I have been programming for a long time, but still fairly new to WPF. Thanks for the help.

XAML

<MyComboBox Name="myTemplate5" MyLookup="Lookup" MyFilter="att_idn=-37" MyData="Detail" MyName="comp_tmpl_idn_srt" ModCde="31" MyEmptyValue="0" ToolTip="Have a nice day" Margin="0,2.5,30,2.5" MinWidth="120" Grid.Column="1"  SelectionChanged="myTemplate5_SelectionChanged" />

C#

private void myTemplate1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    MyComboBox work = sender as MyComboBox;
    if (work != null && work.HasSelectionChanged(e))
    {
        int compTmplId = int.Parse(work.SelectedValue.ToString());
        if (!_wpfIsDumb && !ChangeComponent(compTmplId))
        {
            _wpfIsDumb = true;
            work.SelectedItem = e.RemovedItems[0];
            _wpfIsDumb = false;
        }
    }
}

public bool HasSelectionChanged(SelectionChangedEventArgs e)
{
    if (e.RemovedItems.Count > 0 && e.AddedItems.Count > 0)
        return true;
    else
        return false;
}
  • 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-07T18:33:31+00:00Added an answer on June 7, 2026 at 6:33 pm

    You can achieved this by setting the SelectedIndex to 0.

    XAML:

    <ComboBox Name="myCB" 
                      SelectedIndex="0"
                      MaxWidth="200" MaxHeight="25" />
    

    Code-behind:

    namespace nsComboBox
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                myCB.Items.Add("Item 1");
                myCB.Items.Add("Item 2");
                myCB.Items.Add("Item 3");
    
                myCB.SelectedIndex = 0;
            }     
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to change a very small part of the WPF ComboBox's
I have a WPF containing a dynamically created DataGridComboBoxColumn this has a comboBox that
I have a wpf program in c# that has a combobox with various colors
I have a WPF CustomControl that is derived from ComboBox and I'm trying to
I have a WPF / XAML Window that contains a ComboBox that is giving
I have a comboBox that has a datatrigger that set its SelectedIndex based on
So I have several comboboxes in my WPF application that don't change the selection
I have a WPF combobox control bound to a edm field in a database
I have a WPF user control that contains a DataGrid. This DG contains several
I have a WPF ComboBox and I want to go to items that start

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.