I am trying to bind to a static property on a static class,
this property contains settings that are deserialized from a file.
It never works with the following XAML :
<Window.Resources>
<ObjectDataProvider x:Key="wrapper" ObjectType="{x:Type Application:Wrapper}"/>
</Window.Resources>
<ScrollViewer x:Name="scrollViewer" ScrollViewer.VerticalScrollBarVisibility="Auto"DataContext="{Binding Source={StaticResource wrapper}, UpdateSourceTrigger=PropertyChanged}">
<ComboBox x:Name="comboboxThemes"
SelectedIndex="0"
SelectionChanged="ComboBoxThemesSelectionChanged"
Grid.Column="1"
Grid.Row="8"
Margin="4,3" ItemsSource="{Binding Settings.Themes, Mode=OneWay}" SelectedValue="{Binding Settings.LastTheme, Mode=TwoWay}" />
It does work by code however :
comboboxThemes.ItemsSource = Settings.Themes;
Any idea ?
Thank you 🙂
I have found the answers !
It did silently throw an Exception has been thrown by the target of an invocation i didn’t know more …
I was initializing a log that writes to a file; the designer finally showed up the details of the exception, it was looking for creating the file in Visual Studio directory which is in Program Files, hence a security exception was thrown.
Apparently VS copies the file to its folder, for its Designer.
I fixed it like this :
Last but not least, using ObjectDataProvider never worked as well, only through x:Static
This was driving me totally crazy for a few days as it’s not so hard to bind data; I just learned another lesson !