/// <summary>
 /// Recalculates the size of the presenter to match its parent.
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event args</param>
 private void OnSizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (_presenter != null)
     {
         ExpanderView     parent = _presenter.GetParentByType <ExpanderView>();
         GeneralTransform gt     = parent.TransformToVisual(_presenter);
         Point            childToParentCoordinates = gt.TransformPoint(new Point(0, 0));
         _presenter.Width = parent.RenderSize.Width + childToParentCoordinates.X;
     }
 }
        /// <summary>
        /// IsExpandedProperty changed handler.
        /// </summary>
        /// <param name="obj">The dependency object.</param>
        /// <param name="e">The event information.</param>
        private static void OnIsExpandedPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ExpanderView source = (ExpanderView)obj;

            RoutedEventArgs args = new RoutedEventArgs();

            if ((bool)e.NewValue)
            {
                source.OnExpanded(args);
            }
            else
            {
                source.OnCollapsed(args);
            }

            source.UpdateVisualState(source._useTransitions);
        }
        /// <summary>
        /// IsNonExpandableProperty changed handler.
        /// </summary>
        /// <param name="obj">The dependency object.</param>
        /// <param name="e">The event information.</param>
        private static void OnIsNonExpandablePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ExpanderView source = (ExpanderView)obj;

            if ((bool)e.NewValue)
            {
                if (source.IsExpanded)
                {
                    source._useTransitions = false;
                    source.IsExpanded      = false;
                }
            }
            else
            {
                source._useTransitions = true;
            }

            source.UpdateVisualState(source._useTransitions);
        }
        /// <summary>
        /// NonExpandableHeaderTemplate changed handler.
        /// </summary>
        /// <param name="obj">The dependency object.</param>
        /// <param name="e">The event information.</param>
        private static void OnNonExpandableHeaderTemplatePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ExpanderView source = (ExpanderView)obj;

            source.OnNonExpandableHeaderTemplateChanged((DataTemplate)e.OldValue, (DataTemplate)e.NewValue);
        }
        /// <summary>
        /// ExpanderProperty changed handler.
        /// </summary>
        /// <param name="obj">The dependency object.</param>
        /// <param name="e">The event information.</param>
        private static void OnExpanderPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ExpanderView source = (ExpanderView)obj;

            source.OnExpanderChanged(e.OldValue, e.NewValue);
        }