Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Set MyCb.SelectedItem to null before NameOptions is updated. SelectedItem supersedes Text and when the ItemsSource is updated it will also try to update the Text supposedly connected to the SelectedItem.</p> <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged { public List&lt;String&gt; NameOptions { get { MyCb.SelectedItem = null; // &lt;--- THIS is the solution. just try it! List&lt;String&gt; result = new List&lt;String&gt;(); result.Add(String.Format("{0} {1}", FirstName, LastName)); result.Add(String.Format("{1}, {0}", FirstName, LastName)); result.Add(String.Format("{1}, {0} MI", FirstName, LastName)); return result; } } public event PropertyChangedEventHandler PropertyChanged; public MainWindow() { InitializeComponent(); } private String _theName; public String TheName { get { return _theName; } set { _theName = value; PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("TheName")); } } } private String _firstName; public String FirstName { get { return _firstName; } set { _firstName = value; PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("NameOptions")); handler(this, new PropertyChangedEventArgs("FirstName")); } } } private String _lastName; public String LastName { get { return _lastName; } set { _lastName = value; PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("NameOptions")); handler(this, new PropertyChangedEventArgs("LastName")); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload