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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:51:49+00:00 2026-06-04T04:51:49+00:00

I am binding a combobox in the WPF using MVVM pattern. I am able

  • 0

I am binding a combobox in the WPF using MVVM pattern. I am able to bind a list of string with the combobox but I don’t know how to set a default value in the combobox.
Well I have a list of names which has “A”,”B”,”C” and “D”. Now I want that by default “A” should come as default value.

Thanks

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModel="clr-namespace:WpfApplication1.ViewModel"
    Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
    <ViewModel:NameViewModel></ViewModel:NameViewModel>
</Window.DataContext>
<Grid>
    <ComboBox Height="23" Width="120" ItemsSource="{Binding Names}"/>
</Grid>

public class NameViewModel
{
   private IList<string> _nameList = new List<string>();
   public IList<string> Names { get; set; }
   public NameViewModel()
   {
       Names = GetAllNames();
   }

   private IList<string> GetAllNames()
   {
       IList<string> names = new List<string>();
       names.Add("A");
       names.Add("B");
       names.Add("C");
       names.Add("D");
       return names;
   }
}
  • 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-04T04:51:51+00:00Added an answer on June 4, 2026 at 4:51 am

    I think you should try to use ListItem. ListItem has Selected property

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

Sidebar

Related Questions

I'm using MVVM to bind a ComboBox to an ObservableCollection in my WPF-application. However,
I'm using WPF/MVVM and am having a binding issue with a ComboBox - any
I have a WPF ComboBox and am using MVVM to bind the ItemsSource and
I'm writing an application in WPF using the MVVM-pattern and will really often use
I'm creating a WPF application using the MVVM design pattern that consists of a
I have an application I am creating in WPF, using MVVM pattern. In this
I am using WPF and an MVVM pattern. All the comboboxes that are bound
I'm using Entity Framework 4 and WPF with the MVVM pattern. Now I'm facing
I have a WPF/MVVM (using MVVM-Light) app setup with a ComboBox that is inside
I have a WPF CombBox as follows: <ComboBox ItemsSource={Binding Source={StaticResource myList}} SelectedItem={Binding Path=mySelectedItem} />

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.