Wpf combobox text not updating

Posted by / 13-Jul-2020 13:59

Object Instance = obj1 End Sub Private Sub btn_List2_Click(By Val sender As System. This method uses the Equals method to determine equality. However, when I click a button to switch the Object Instance to obj2, the Combo Box Items Source gets populated correctly in the dropdown, but the Selected Value is set to Nothing instead of being equal to obj2. Problem: The Combo Box class searches for the specified object by using the Index Of method. took me more than a week to resolve this small fyn. In WPF, everytime you navigate to a Page everything gets re-initialized, constructor gets called, loaded methods, everything.so if you are setting your Data Context inside your View you will no doubt be blowing away that Selected Item that the user selected.(Note - the values in the combobox list do update).

It turned out that when I added a check to make sure the proposed value for Key Type was not null, everything worked as expected. So i wrote a class Equality Brush containing a Brush and implementing Equals: It could be the way you are applying the Data Context to the Page.

I think this could be done in the template of the combobox - somehow make the textbox be bound to the selecteditem of the combobox, or always update when it updates?

EDIT: I didn't make clear - I do implement INotify Property Changed properly and when the value changes I raise Property Changed for my List and my Selected Item.

So you will need to ensure that you are setting the Data Context on Initialize (either externally or within the constructor) rather than Load.

However, this will only work for that instance of the Page.

wpf combobox text not updating-38wpf combobox text not updating-30wpf combobox text not updating-87

One thought on “wpf combobox text not updating”

  1. Manchester Mature Dating Meet people casually and share your interests at one of the many events we hold across the UK. Privacy: The information you provide will be used by International Limited and/or Dating Limited, Meetic’s group companies (by which we mean Meetic, any parent company of Meetic, and any subsidiaries of Meetic or its parent company), and their service providers located within and outside of the European Union (described herein as, the “Meetic Group”) in order to provide you with access to the Meetic Services.

  2. Hey, his friends may be d-bags, but they may have influence over what your man thinks. Do a little sucking up to the boys before you reveal your inner bitch. Healthy competition can definitely spice up a game of pool or a sesh with your man, but some girls take it too far.