Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchorable Panes not working in a ViewModel First MVVM approach (Stylet) #391

Closed
montyjohn opened this issue Oct 26, 2022 · 2 comments
Closed

Comments

@montyjohn
Copy link

I'm trying to use AvalonDock with Stylet. Stylet is a ViewModel first MVVM framework, but I just can't get them to play nicely together, and I'm not sure if the problem is with my code, Stylet or AvalonDock.

ViewModels for Layouts and Anchorable Layouts are held in ObervableCollections. Stylet should then automatically find the relevant View based on its name.

I'm finding that new Layouts works fine with Stylet, but the new Anchorable Layout throws the error of 'Unable to transform ViewModel name AvalonDock.Layout.LayoutAnchorable into a suitable View name'.

I've made a barebones app that replicates the problem here if there's anyone kind enough to have a play to see if they can figure out where the problem is.

https://github.com/montyjohn/StyletAvalonDockTest.git

What's quite odd is if I remove the AvalonDock 2013 Light Theme form the XAML, or change it to another Theme, then I get the above error with both Layouts and Anchorable Layouts.

The issue doesn't appear to be with the ViewModels themselves as I can throw a Anchorable Layout in the Layout ObservableCollection and it works fine.

Any help would be much appreciated.

@canton7
Copy link

canton7 commented Oct 27, 2022

See also canton7/Stylet#366.

This is because when LayoutItemTemplate is used with LayoutAnchorable, the DataContext available to bindings in the LayoutItemTemplate is a ContentControl, whose Content property is the LayoutAnchorable. That's different to when the LayoutItemTemplate is applied to a LayoutDocument: in that case, the DataContext is the LayoutDocument itself.

@Dirkster99
Copy link
Owner

I guess this issue is resolved so I close this entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants