This project is read-only.

Binding ItemsSource to a collection of view models

Aug 26, 2010 at 7:21 PM

I may be missing something but it appears that the ItemsSource on the Pane abstract class can only be a collection of ManagedContent classes.  This seems quite contrary to the general architecturual philosophy of WPF.  I would like to bind to a collection of view models and specify a data template in the ItemTemplate property that defines the ManagedContent control I want displayed in the pane.

This seems to be a crippling limitation of AvalonDock.  Is there another way to do this I have not noticed?

Aug 27, 2010 at 7:06 AM

hi jonathan,

take a look at this

this behavior is not completely ready, but there not much work to do.

Aug 27, 2010 at 4:28 PM

I guess that could work but why not use an ItemContainerGenerator?  I haven't done much custom control development but I was always under the impression that class was intended for this exact scenario.  The ItemsSource can contain a collection of any data class and does not need to be a UIElement.  The ItemContainerGenerator is responsible for creating a UIElement that for each data class in the ItemsSource collection.  I think that might end up being easier than getting deep into behaviors.

Aug 27, 2010 at 7:22 PM

I'm not the developer here. I used this library too and had the same problems like you, so I needed a solution, that independent of the AvalonDock version. I ended up with this behavior. The bigger problem with this library is poor performance (especially on my x64 server, don't know why but it looks WPF use software rendering in it) and some bugs that makes this library unusable for me.

* Can't set size on new DockableContent
* Problems with possible Docking positions and bugs, when you set it on e.g. Left only
* ...

So I'm working on my own MDI Control now. It's not so powerful like AvalonDock, but it's fast and easy to use. With a little bit more time, it's easy to improve to something like AvalonDock. For now it's good enough for me and so I have other priorities.

It use "standard" TabControls (more precise TabControlEx from sachabarber - Cinch V2 library) and filter behavior to show the toolwindows on places it should.

Aug 27, 2010 at 7:29 PM

Sorry, I wasn't trying to complain and I definitely wasn't trying to complain to a guy who didn't write the control.  :-)

I was planning on using this primarily for an MDI manager also.  The docking abilities were a giant plus but not the main goal.

If I get time in a couple of weeks I might modify the ItemsSource usage in AvalonDock and see if they'll take it as a submission.

Sep 12, 2010 at 4:14 PM

@Jonathan, did you manage to try modifying the source to support the binding scenarios you mentioned? It also seems to me as a crippling limitation, and I spent quite a lot of time trying to work around it, and failed for various reasons. Maybe if we pool our resources together we could make a fork or contribution? :P

Of course, properly supporting all the features is not really possible using this architecture - for instance undocking windows (floating); but binding to a collection of arbitrary templated items, both for DocumentPane and DockablePane, should be possible.