我正在使用AvalonDock作为我的WPF应用程序,并希望使用数据绑定来更改主题。
视图模型:
private Theme _AvalonDockTheme = new ExpressionDarkTheme();
public Theme AvalonDockTheme
{
get
{
return _AvalonDockTheme;
}
set
{
if (_AvalonDockTheme != value)
{
_AvalonDockTheme = value;
RaisePropertyChanged("AvalonDockTheme");
}
}
}
XAML:
<xcad:DockingManager AllowMixedOrientation="True"
Theme="{Binding Source={StaticResource DockTheme}}"
x:Name="_dockingManager">
<!-- some content -->
</xcad:DockingManager>
我使用此功能时收到以下错误消息:
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='Xceed.Wpf.AvalonDock.Themes.ExpressionDarkTheme' BindingExpression:Path=MainViewModel.AvalonDockTheme; DataItem='App' (HashCode=47182344); target element is 'CollectionViewSource' (HashCode=42887454); target property is 'Source' (type 'Object')
我不明白绑定失败的原因。绑定源和目标都是Xceed.Wpf.AvalonDock.Themes.Theme类型,但错误消息表明目标元素的类型为CollectionViewSource。为什么呢?
答案 0 :(得分:1)