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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:21:30+00:00 2026-05-16T15:21:30+00:00

I have recently started using the MVVM-Light toolkit and I am stuck on the

  • 0

I have recently started using the MVVM-Light toolkit and I am stuck on the following problem: I have a basic Silverlight Combobox that is bound to a viewmodel with an ObservableCollection of type MyUser. The Combobox implements a custom DataTemplate to combine the user’s name and surname. After loading the list of users, how do I set the Combobox to select the first user in the list and display this selected user in the collapsed Combobox? I know that it has been suggested to use the SelectedValue property but I have not been able to get it to work using either SelectedItem or SelectedValue. Put another way, even though I set the SelectedValue/SelectedItem after the list of users has been loaded the selected MyUser does not display as selected in the combobox, how do I achieve this? Please see the XAML below:

<ComboBox
    ItemsSource="{Binding MyUsers, Mode=OneWay}"
    SelectedItem="{Binding SelectedUser, Mode=TwoWay}"
    IsEnabled="{Binding IsReady}">
       <ComboBox.ItemTemplate>
           <DataTemplate>
               <StackPanel Orientation="Horizontal">
                  <TextBlock Text="{Binding Name}"></TextBlock>
                  <TextBlock Text=" "></TextBlock>
                  <TextBlock Text="{Binding Surname}"></TextBlock>
               </StackPanel>
           </DataTemplate>
       </ComboBox.ItemTemplate>
 </ComboBox>

The View Model Code is as follows:

public ObservableCollection<MyUser> MyUsers
{
    get
    {
        return myUsers;
    }
    set
    {
        if (myUsers == value)
        {
            return;
        }
        myUsers = value;
        SelectedUser = myUsers.FirstOrDefault();
        IsReady = true;
        RaisePropertyChanged("MyUsers");
    }
}

public MyUser SelectedUser
{
    get
    {
        return selectedUser;
    }
    set
    {
        if (selectedUser == value)
        {
            return;
        }
        selectedUser = value;
        RaisePropertyChanged("SelectedUser");
    }
}
  • 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-16T15:21:31+00:00Added an answer on May 16, 2026 at 3:21 pm

    The answer is simple, you have to raise the PropertyChanged event for the List of MyUsers before setting the Selected User in the viewModel, i.e. notify the UI that the ItemsSource has changed before updating the SelectedValue.

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

Sidebar

Related Questions

We have recently started using git and had a nasty problem when someone committed
I have recently started using Zend Studio which has reported as warning the following
I have recently started using generics in java, and in that attempt tried to
I've recently started using ctags on my projects. I currently have the following setup:
I have recently started using Vim as my text editor and am currently working
I have recently started working on a very large C++ project that, after completing
I have recently started using CAML.NET IntelliSense for SharePoint with Visual Studio 2008; which
I have recently started using Google Webmaster Tools . I was quite surprised to
I have recently started using DocCheck for checking the validity of JavaDoc's in code
I have recently started using Zend Framework. I started developing on my local XAMPP

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.