/// <summary> /// Creates the <see cref="Panel"/> when <see cref="ApplyTemplate"/> is called for the first /// time. /// </summary> private void CreatePanel() { ClearVisualChildren(); Panel = ItemsPanel.Build(); Panel.SetValue(TemplatedParentProperty, TemplatedParent); if (!Panel.IsSet(KeyboardNavigation.DirectionalNavigationProperty)) { KeyboardNavigation.SetDirectionalNavigation( (InputElement)Panel, KeyboardNavigationMode.Contained); } AddVisualChild(Panel); var logicalHost = this.FindReparentingHost(); if (logicalHost != null) { ((IReparentingControl)Panel).ReparentLogicalChildren( logicalHost, logicalHost.LogicalChildren); } KeyboardNavigation.SetTabNavigation( (InputElement)Panel, KeyboardNavigation.GetTabNavigation(this)); _createdPanel = true; CreateItemsAndListenForChanges(Items); }
/// <summary> /// Creates the <see cref="Panel"/> when <see cref="ApplyTemplate"/> is called for the first /// time. /// </summary> private void CreatePanel() { Panel = ItemsPanel.Build(); Panel.SetValue(TemplatedParentProperty, TemplatedParent); if (!Panel.IsSet(KeyboardNavigation.DirectionalNavigationProperty)) { KeyboardNavigation.SetDirectionalNavigation( (InputElement)Panel, KeyboardNavigationMode.Contained); } LogicalChildren.Clear(); VisualChildren.Clear(); LogicalChildren.Add(Panel); VisualChildren.Add(Panel); KeyboardNavigation.SetTabNavigation( (InputElement)Panel, KeyboardNavigation.GetTabNavigation(this)); _createdPanel = true; CreateItemsAndListenForChanges(Items); }