Using control that inherits from Panel instead of ContentControl

Aug 31, 2010 at 6:45 PM

Does Caliburn micro have anything built-in to deal with using a control that inherits from System.Windows.Controls.Panel instead of using a ContentControl? My view needs to be added to the Children collection property. I can't use a ContentControl because I am using a third party control for layout and it inherits from System.Windows.Controls.Panel. I tried the ContentControl but it throws the scaling/rendering off for my third party control.

Aug 31, 2010 at 8:09 PM

Have you tried using an ItemsControl with a custom panel template? That is the preferred which I have used many times.

Aug 31, 2010 at 8:45 PM
Edited Aug 31, 2010 at 8:48 PM

Thanks for the quick reply but as I was trying what you mentioned I realized that I can override the ContentControl control template, duh! Sometimes I get so caught up with the code that I forget that the visual rendering of a control can be overriden Anyway I just applied my custom style and everything works great. I have to thank you for sharing this awesome framework with the community. You have saved me countless hours of doing mundane "plumbing" code.

Aug 31, 2010 at 9:04 PM
Edited Aug 31, 2010 at 9:15 PM

Roberto, you can see an example of this in the ManyViewModels sample: 

In that sample the View has

    <ItemsControl x:Name="Tiles">

and the ViewModel has 
public BindableCollection<SimpleTileViewModel> Tiles { get; private set;}

Does this fit what you're needing?

Aug 31, 2010 at 9:34 PM
Edited Sep 1, 2010 at 1:54 AM

Well, yes but I realized that it could be done without having to use an ItemsControl. It is a single view that I needed and the problem was the third party control that inherited from Panel instead of contencontrol that needed to be my container. The solution was just to change the ContentControl template to use the third party control.