Custom Controls

Aug 22, 2010 at 5:33 PM

I don't think this is the standard custom controls question, but it is probably related.

I have a third party control that derives from ItemsControl, and requires that all items are derived from a specific type. For example, a docking host requiring that all child items / windows derive from docking window. In my current model, the ShellView / ShellViewModel contains the docking site, and has a tool window that is MyToolView / MyToolViewModel. I used a ContentControl bound to a  property on ShellViewModel that exposes the MyToolViewModel. All compiles well, but at run time, the dock site class complains that it cannot add types not derived from DockingWindow. If I go view first, I can solve this problem, but I prefer to stay view-model first if possible.

Any suggestion on how to deal with this? Or should I just go view-first for this case?

Aug 23, 2010 at 2:25 AM

I can bind the content of the docking ToolWindow to a view-model using cal:View.Model="{Binding Binder}". However, the tool window, and anything else in the docking site, was not directly bindable without modifying ExtensionMethods.GetNamedElementsInScope.

How are others dealing with third party controls, or even their own custom controls?

Aug 23, 2010 at 2:52 AM

To be more clear I did this as view-first in the body of the ToolWindow, so the cal:View.Model binding was set on the view inside the ToolWindow.