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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:30:02+00:00 2026-05-13T16:30:02+00:00

Consider the following XAML: <ComboBox Name=CompanyComboBox HorizontalAlignment=Stretch ItemsSource={Binding Path=GlobalData.Companies} SelectedValuePath=Id SelectedValue={Binding Customer.CompanyId, ValidatesOnDataErrors=True} DisplayMemberPath=Name

  • 0

Consider the following XAML:

<ComboBox Name="CompanyComboBox" 
    HorizontalAlignment="Stretch"
    ItemsSource="{Binding Path=GlobalData.Companies}" 
    SelectedValuePath="Id"
    SelectedValue="{Binding Customer.CompanyId, ValidatesOnDataErrors=True}"
    DisplayMemberPath="Name" />

GlobalData.Companies is a collection (IEnumerable<Company>) of companies; this collection can be reloaded on background (it is downloaded from a webservice). When this happens, ComboBox correctly reloads items via binding. However as a side-effect, it also resets the selected item!

I have used Reflector to inspect combo-box sources and apparently this is intended behavior.

Is there any “nice” way how to get around this? What I want to achieve, is that if the user selects “Company A” and reloads list of companies afterwards, then “Company A” stays selected (assuming it is in the new list).

  • 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-13T16:30:02+00:00Added an answer on May 13, 2026 at 4:30 pm

    Maybe you can use ObservableCollection<Company> instead of your IEnumerable<Company>? Then, on background change you would only Add / Remove items that are new / absent in the new list, selected item should stay, unless it was removed by the change.

    You can update your observable collection in a separate thread with a small hack-around.

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

Sidebar

Related Questions

Consider the following XAML (a UserControl): <Grid x:Name=LayoutRoot ScrollViewer.VerticalScrollBarVisibility=Disabled> <Grid HorizontalAlignment=Right Width=335.312 ScrollViewer.VerticalScrollBarVisibility=Disabled> <ed:BlockArrow
Consider the following, simple code: XAML: <Grid Height=60 Name=grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=162* /> <ColumnDefinition
Consider the following XAML file: <Window x:Class=ExpressionVisualizer.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:sle=clr-namespace:System.Linq.Expressions;assembly=System.Core Title=MainWindow Height=350 Width=525> <Window.Resources>
Consider the following piece of Xaml <Grid Background=Blue> <Border Width=100 Height=60 BorderBrush=Black BorderThickness=2> <Border
I have the following XAML: <ListBox SelectedItem={Binding SelectedTeam}> <ListBoxItem Content={Binding Match.HomeTeam} /> <ListBoxItem Content={Binding
Consider the following code: <Window x:Class=WpfApplicationWPF.CommandsWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=CommandsWindow Height=300 Width=300 PreviewMouseUp=Window_PreviewMouseUp MouseUp=Window_MouseUp >
Consider the following XAML: <Window x:Class=ContextMenuEvent.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350 Width=525 ContextMenuOpening=Window_ContextMenuOpening> <Grid> <Button>Ok</Button>
Consider following JavaScript object var planet = { id: 1001, Name: Mars, faction: {
Consider following situation: there is ComboBox and a filter TextBox, then user types a
Consider the following xaml snippet: <ToolBarTray> <ToolBar Band=1 BandIndex=1> <Button>Go</Button> <Separator></Separator> <Button>Camera 1</Button> <Button>Camera

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.