Conventions for Accordion and AccordionItem?

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

Anybody figured out how to do these already?

I have posted the question on StackOverflow:

http://stackoverflow.com/questions/6542381/caliburn-micro-convention-for-accordion-and-accordionitem

Coordinator
Jul 1, 2011 at 3:26 AM

Have a look at the WPF TabControl convention under source.

Jul 1, 2011 at 8:57 AM

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

		    ConventionManager.AddElementConvention<AccordionItem>(
                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 10:21 AM

Hi

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

Coordinator
Aug 5, 2011 at 2:39 PM

@saldoukhov

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

@banthaza

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

Aug 5, 2011 at 7:51 PM

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