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

  • Home
  • SEARCH
  • 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 8928833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:32:16+00:00 2026-06-15T08:32:16+00:00

I have the following WPF Combobox: <Window.Resources> <CollectionViewSource x:Key=performanceItemsource Source={Binding Path=SelectedReport.Performances} > <CollectionViewSource.SortDescriptions> <scm:SortDescription

  • 0

I have the following WPF Combobox:

<Window.Resources>
    <CollectionViewSource x:Key="performanceItemsource" Source="{Binding Path=SelectedReport.Performances}"  >
        <CollectionViewSource.SortDescriptions>
            <scm:SortDescription PropertyName="Name"/>
        </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>
</Window.Resources>
 ...
    <ComboBox Name="cbxPlanPerf" Grid.ColumnSpan="2"
      SelectedValuePath="MSDPortfolioID" DisplayMemberPath="Name" 
      SelectedValue="{Binding Path=PlanPerfID}"
      ItemsSource="{Binding Source={StaticResource performanceItemsource}}"/>

The Source for the CollectionViewSource is:

public List<MSDExportProxy> Performances
{
  get
  {
    if (Portfolio != null)
    {
      return (from a in Portfolio.Accounts where a.MSDPortfolioID != null select new MSDExportProxy(a))
        .Concat<MSDExportProxy>(from g in Portfolio.Groups where g.MSDPortfolioID != null select new MSDExportProxy(g))
        .Concat<MSDExportProxy>(from p in new[] { Portfolio } where p.MSDPortfolioID != null select new MSDExportProxy(p))
        .ToList<MSDExportProxy>();
    }
    return new List<MSDExportProxy>();
  }
}

The bound property PlanPerfID is a string.

I move between records using a ListBox control. The ComboBox works fine if the previous record had no items in its ComboBox.ItemsSource. If there were any items in the previous record’s ComboBox.ItemsSource then the new record won’t find its matching item in the ItemsSource collection. I’ve tried setting the ItemsSource in both XAML and the code-behind, but nothing changes this odd behavior. How can I get this darn thing to work?

  • 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-15T08:32:18+00:00Added an answer on June 15, 2026 at 8:32 am

    I found a quick and dirty solution to my problem. I just happen to have a public NotifyPropertyChanged() method on my Report entity and I discovered that if I called SelectedReport.NotifyPropertyChanged("PlanPerfID") in the Report ListBox’s SelectionChanged event that it was enough of a jolt to get the ComboBox to re-evaluate and find its matching item in the ItemsSource. Yeah, it’s KLUGE…

    UPDATE: I also wound up needing to add SelectedReport.NotifyPropertyChanged("Performances") for some situations…

    UPDATE 2: Okay, turns out the above wasn’t bullet proof and I ran across a situation that broke it so I had to come up with a better workaround:

    1. Altered the SelectedReport property in the Window’s code-behind, adding a private flag (_settingCombos) to keep the Binding from screwing up the bound values until the dust has settled from changin the ItemSource:

      private bool _settingCombos = false;
      private Report _SelectedReport;
      public Report SelectedReport
      {
        get { return _SelectedReport; }
        set 
        {
          _settingCombos = true;
          _SelectedReport = value;
          NotifyPropertyChanged("SelectedReport");
        }
      }
      
    2. Created a proxy to bind to in the Window code-behind that will refuse to update the property’s value if the _settingCombos flag is true:

      public string PlanPerfID_Proxy
      {
        get { return SelectedReport.PlanPerfID; }
        set
        {
          if (!_settingCombos)
          {
            SelectedReport.PlanPerfID = value;
            NotifyPropertyChanged("PlanPerfID_Proxy");
          }
        }
      }
      
    3. Added an extra Notification in the Report ListBox’s SelectionChanged event along with code to reset the _settingCombos flag back to false:

      private void lbxReports_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
        //KLUGE: Couldn't get the ComboBoxes associated with these properties to work right
        //this forces them to re-evaluate after the Report has loaded
        if (SelectedReport != null)
        {
          NotifyPropertyChanged("PlanPerfID_Proxy");
          _settingCombos = false;
        }
      }
      
    4. Bound the ComboBox to the PlanPerfID_Proxy property (instead of directly to the SelectedReport.PlanPerfID property.

    Wow, what a hassle! I think that this is simply a case of .NET’s binding logic getting confused by the dynamic nature of the ComboBox.ItemSource, but this seems to have fixed it. Hope it helps someone else.

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

Sidebar

Related Questions

I have the following ControlTemplate for a WPF TabItem: <ControlTemplate x:Key=DefaultTabItemTemplate TargetType={x:Type TabItem}> <ControlTemplate.Resources>
I have following WPF ListView: <ListView Grid.Column=2 Grid.Row=1 Margin=0,53,12,6 Name=lvwProperties ItemsSource={Binding Path=SelectedPropertyItems, Mode=TwoWay} Grid.ColumnSpan=2>
I have following DataGrid in wpf. <DataGrid AutoGenerateColumns=False Grid.Row=1 Name=adsGrid ItemsSource={Binding Path=Ads} CanUserAddRows=False CanUserDeleteRows=False
I have the following Combo box binding which was within a WPF window. I
I have the following dependency property in my MainWindow class (inherits from WPF's Window)
I am NEW to WPF. I have the following XAML code: </Window> ... <Canvas>
I have the following WPF window definition but the focus/lost focus events are not
I have the following WPF application <Window x:Class=Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=clr-namespace:WpfApplication1 Title=Window1 Height=300 Width=300>
I have the following wpf control added to xaml: <ListView Margin=22,80,271,12 Name=listView1 ItemsSource={Binding} />
I have a combobox on a window in wpf and i am trying to

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.