TwoWay Binding of a ComboBox to a static property in .NET 4.5
===

Well, i just posted [this][1] question, but i figured that i am not doing anything wrong. My code (and the code of all of the answers) is correct, but my dev-maschine runs with .NET4.5 which apparently has a problem with the binding of the combobox...

So here a new version of the question: **How to two-way bind a combobox's SelectedItem to a static Property in .NET4.5?**

The following code snippets work in .net4 but not in .NET4.5. In 4.5 it is just that the selected value is not propagated back into my static property.

My ViewModel:

    public class MainWindowViewModel
    {
        public static List<String> MyElements { get; set; }
        public static string SelectedElement { get; set; }

        static MainWindowViewModel()
        {
            MyElements = new List<string>() {"a", "b", "c"};
            SelectedElement = "a";
        }
    }
And my XAML

    <Window.Resources>
        <me:MainWindowViewModel x:Key="model"/>
    </Window.Resources>

    <StackPanel>
        <ComboBox
            ItemsSource="{Binding Source={x:Static me:MainWindowViewModel.MyElements}, Mode=OneWay}"
            SelectedItem="{Binding Source={StaticResource model}, Path=SelectedElement}" />
    </StackPanel>
Does anybody have an idea how to achieve this two-way binding of a ComboBox's SelectedItem to a static Property in .NET4.5?


  [1]: http://stackoverflow.com/questions/11468502/twoway-binding-of-a-combobox-to-a-static-property