This is a typical case of elements that look the same, but not because they have different links (read C # reference types ).
You load a ComboBox with three values, and these 3 values ββare displayed in a drop-down list. To see the selected item when the ComboBox closed, it must be (= have the same link) as one of these 3 values. If nothing is saved in the roaming settings, you select the first option as SelectedItem . By switching to another selected item, you will also receive a valid link in the SelectedItem property.
However, when deserializing the saved RoamingSettings value RoamingSettings you create a new object with a different reference. When you set this element as SelectedItem , the ComboBox control will not find it in its elements and therefore will not select the element.
To fix this, you need to find the correct item in the ItemSource collection:
var value = (string)roamingSettings.Values["ComboBoxSelection"]; if (value != null) { var deserialized = Deserialize<ComboBoxItem>(value);
source share