Conventions for Accordion and AccordionItem?

Topics: Conventions
Jul 1, 2011 at 12:16 AM

Anybody figured out how to do these already?

I have posted the question on StackOverflow:

Jul 1, 2011 at 2:26 AM

Have a look at the WPF TabControl convention under source.

Jul 1, 2011 at 7:57 AM

Well, the best I could come up with was (after setting accordion's ContentTemplate to DefaultItemTemplate)

                AccordionItem.ContentProperty, "DataContext", "Loaded")
		        .ApplyBinding = (viewModelType, path, property, element, convention) =>
                    if (!ConventionManager.SetBinding(viewModelType, path, 
                        property, element, convention)) return false;
                    var accordionItem = (AccordionItem)element;
                    accordionItem.HeaderTemplate = ConventionManager.DefaultHeaderTemplate;
                    return true;

But it does not even enter the lambda. 
P.S. The documentation does not give a good explanation of the parameters in the .AddElementConvention method. 
Do I understand correctly that in the code above it says: "when AccordionItem is loaded, bind Content to the "DataContext"?

Aug 5, 2011 at 9:21 AM


I'm new to the caliburn framework and was wondering where you would apply this code?

Aug 5, 2011 at 1:39 PM


It's possible that the convention system is not able to find the AccordionItems, but only the Accorion. What is the base class for Accordion? Can you send me a sample project that demonstrates the problem? Send to robertheisenberg at hotmail dot com


You would place this code in the Configure override of the Bootstrapper.

Aug 5, 2011 at 6:51 PM

Take a look at my StackOverflow answer linked above, it contains the complete convention.