Convention for binding Panorama ItemSource

Apr 26, 2011 at 1:13 PM

Is there a convention to bind panorama's ItemSource to a collection? I thinks one needs to be written but i don't really know the convention code well enough at the moment.

Coordinator
Apr 26, 2011 at 2:40 PM

Have a look at the samples....

Apr 26, 2011 at 3:14 PM

Can you point out which one, i can't see it in the WP7 Sample

Coordinator
Apr 26, 2011 at 4:15 PM

It's there in the bootstrapper in the method called AddCustomConventions.

Apr 26, 2011 at 4:48 PM

isn't that just for binding the Header Template and SelectedItem, not the ItemSource?

Coordinator
Apr 26, 2011 at 4:53 PM
Edited Apr 26, 2011 at 4:56 PM

It does four things.

ConventionManager.AddElementConvention<Panorama>(Panorama.ItemsSourceProperty, "SelectedItem", "SelectionChanged").ApplyBinding =
                (viewModelType, path, property, element, convention) => {
                    if(ConventionManager
                        .GetElementConvention(typeof(ItemsControl)) //ItemsSource and ItemTemplate
                        .ApplyBinding(viewModelType, path, property, element, convention)) {
                        ConventionManager
                            .ConfigureSelectedItem(element, Panorama.SelectedItemProperty, viewModelType, path); //SelectedItem
                        ConventionManager
                            .ApplyHeaderTemplate(element, Panorama.HeaderTemplateProperty, viewModelType); //HeaderTemplate
                        return true;
                    }

                    return false;
                };

Apr 27, 2011 at 1:21 PM

Ah i see, thanks for the help.