Beispiel #1
0
        private static void ItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PowerHub hub = d as PowerHub;

            if (hub != null)
            {
                DataTemplate template = e.NewValue as DataTemplate;
                if (template != null)
                {
                    // Apply template
                    foreach (var section in hub.Sections)
                    {
                        section.ContentTemplate = template;
                    }
                }
            }
        }
Beispiel #2
0
        private static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PowerHub hub = d as PowerHub;

            if (hub != null)
            {
                IList items = e.NewValue as IList;
                if (items != null)
                {
                    hub.Sections.Clear();
                    for (int index = 0; index < items.Count; index++)
                    {
                        var        item    = items[index];
                        HubSection section = new HubSection();
                        if (index == 0)
                        {
                            // N1 only HACK !!! Very Lame!
                            //section.Margin = new Thickness(95, section.Margin.Top, section.Margin.Right,
                            //    section.Margin.Bottom);
                            section.Padding = new Thickness(115, 20, 20, 20);
                        }
                        section.DataContext = item;
                        section.Header      = item;
                        DataTemplate template = hub.ItemTemplate;
                        section.ContentTemplate = template;
                        hub.Sections.Add(section);

                        IViewItem viewItem = item as IViewItem;
                        if (viewItem != null)
                        {
                            section.IsHeaderInteractive = viewItem.IsNavigable;
                            section.SetBinding(HubSection.VisibilityProperty, new Binding()
                            {
                                Converter = new BooleanToVisibilityConverter(),
                                Path      = new PropertyPath("IsVisible"),
                                Mode      = BindingMode.OneWay
                            });
                        }
                    }
                }
            }
        }