uwp add tag
Hosch250 (imported from SE)
I have the following ComboBox:

    <ComboBox SelectedItem="{Binding SelectedTheme, Mode=TwoWay}"
              ItemsSource="{Binding Themes, Mode=OneTime}" />

It is bound to the following values in my VM:

    private Theme _selectedTheme;
    public Theme SelectedTheme
        get { return _selectedTheme; }
            if (_selectedTheme != value)
                _selectedTheme = value;

    public List<Theme> Themes =>

I set `SelectedTheme`s value in the VM's ctor, and the `get` member is being hit after I assign the VM instance to my `Page`'s `DataContext`.  My trouble is the UI does not reflect the binding value the first time I load the page; it updates works correctly all other times, but the combobox does not show any selection after the page is initially loaded.
Top Answer
Hosch250 (imported from SE)
After struggling with this issue for about two hours, I realized that the UWP framework is connecting the bindings in the order they are set, so the `SelectedItem` is being set correctly, but is then cleared when the `ItemsSource` value is set.  Changing my XAML to the following fixes the problem:

    <ComboBox ItemsSource="{Binding Themes, Mode=OneTime}"
              SelectedItem="{Binding SelectedTheme, Mode=TwoWay}" />

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.