【发布时间】:2011-03-01 10:27:56
【问题描述】:
我正在尝试绑定到静态类的静态属性, 此属性包含从文件反序列化的设置。
它永远不会与以下 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}" />
它确实可以通过代码工作:
comboboxThemes.ItemsSource = Settings.Themes;
有什么想法吗?
谢谢你:-)
【问题讨论】:
标签: c# wpf binding static properties