0

I'm using AvalonDock for my WPF Application and want to use data binding for changing the theme.

ViewModel:

    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>

Whe I use this I get the following error message:

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')

I don't understand why the binding fails. The binding source and target are both of type Xceed.Wpf.AvalonDock.Themes.Theme but the error message says that the target element is of type CollectionViewSource. Why?

user37337
  • 317
  • 2
  • 18

1 Answers1

1

Take a look at this question:

Binding a CollectionViewSource within a DataTemplate

If that doesn't help, please provide DockTheme resource definition.

Community
  • 1
  • 1
Ivan Peric
  • 4,263
  • 3
  • 23
  • 32
  • Thank you. You opened my Eyes. It was a copy-paste-mistake. I have declared the resource as a CollectionViewSource because I used this for a List in another window. I have controlled this resource much times but I haven't seen it. No I have changed it to a DataContext. – user37337 Sep 04 '13 at 10:14