Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Combobox loses visual value, but keeps selected value when the page it's on is hidden and reshown
    primarykey
    data
    text
    <p>I'm using a Silverlight 4.0 project that utilizes MVVM and we have a combobox that resides on a view and has its values and selected value bound to an observable collection of Organizations and a SelectedOrganization respectively (both values exist on the viewmodel). With our project the page that this control is on can be hidden or shown. The first load everything looks great but when you go to a different control (hide the tab with the control and then go back to it) the value that is currently selected in the combo box looks like it's blank, but when I debug, the selected value is still there.</p> <p>The visual tree is getting recreated, but I have no idea why the combobox loses the text that should be in the box when the parent page is hidden and then re-shown. All other controls on the page behave correctly (autocompletetextbox, textblocks, textboxes, all of which have data bound to the viewmodel the same way).</p> <p>Here's how the combobox is declared:</p> <pre><code>&lt;ComboBox SelectedItem="{Binding SelectedOrganization, Mode=TwoWay}" ItemsSource="{Binding Organizations}" DisplayMemberPath="Name" Margin="5,0" MinWidth="100" /&gt; </code></pre> <p>the Class for the organization is here:</p> <pre><code>[DataContract] public class Organization { [DataMember] public Guid OrganizationID { get; set; } [DataMember] public string Name { get; set; } } </code></pre> <p>and the viewmodel has the following code for the bindings:</p> <pre><code>public Organization SelectedOrganization { get { return (Organization)GetValue("SelectedOrganization"); } set { SetValue("SelectedOrganization", value); } } public ObservableCollection&lt;Organization&gt; Organizations { get { return (ObservableCollection&lt;Organization&gt;)GetValue("Organizations"); } set { SetValue("Organizations", value); } } </code></pre> <p>What do I need to do to keep the selected value when I switch parent pages?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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