Microsoft.Samples.KMoore.WPFSamples.DateControls.MonthCalendar.AttachToVisualTree C# (CSharp) Method

AttachToVisualTree() private method

Walk to visual tree to find the MonthCalendarContainer. Set the GroupFactory and GroupPanel. Register the selection change event if it is a Selector.
private AttachToVisualTree ( ) : void
return void
        private void AttachToVisualTree()
        {
            DetachFromVisualTree();

            // Walk the visual tree to find the MonthCalendarContainer.
            _mccContainer = GetTemplateChild(c_VisibleDaysHostTemplateName) as MonthCalendarContainer;

            if (_mccContainer != null)
            {
                _mccContainer.ItemsSource = VisibleDays;

                RefreshDayTemplate();

                _mccContainer.LayoutUpdated += new EventHandler(OnContainerLayoutUpdated);
                _mccContainer.SelectionChanged += new SelectionChangedEventHandler(OnContainerSelectionChanged);
                //If MonthCalendar's visualtree is restyled, set this flag to true to update the SelectedDates on new UI
                SetFlag(Flags.IsVisualTreeUpdated, true);
            }

            RefreshPreviousButtonStyle();
            RefreshNextButtonStyle();
        }