コード例 #1
0
        private bool isVisualStateExpanded(IExpanderDataItem item)
        {
            ContentControl contentWrapper = findItemContentWrapperOfItem(item);
            bool           expanded       = contentWrapper.Content != null;

            return(expanded);
        }
コード例 #2
0
        private void collapseItem(IExpanderDataItem item)
        {
            //handle arrow rotation

            //hide previous(rotaded) img
            FrameworkElement prevImage = findItemElement(item, collapsedArrowComponentList);

            prevImage.Visibility = Visibility.Collapsed;

            FrameworkElement arrowComp = findItemElement(item, expandedArrowComponentList);;

            arrowComp.Visibility = Visibility.Visible;

            Visual xamlVisual = ElementCompositionPreview.GetElementVisual(arrowComp);
            var    compositor = xamlVisual.Compositor;
            var    animation  = compositor.CreateScalarKeyFrameAnimation();

            animation.Duration       = TimeSpan.FromSeconds(1.0d);
            animation.IterationCount = 1;
            animation.InsertKeyFrame(0.0f, 0.0f);

            float angle = -90.0f;//

            animation.InsertKeyFrame(1.0f, angle);
            xamlVisual.CenterPoint = new System.Numerics.Vector3(5.0f, 5.0f, 0);
            //animation.StopBehavior = AnimationStopBehavior.SetToFinalValue;

            xamlVisual.StartAnimation("RotationAngleInDegrees", animation);

            // hide item content
            ContentControl contentWrapper = findItemContentWrapperOfItem(item);

            ((UIElement)contentWrapper.Content).Visibility = Visibility.Collapsed;
            contentWrapper.Content = null;
        }
コード例 #3
0
        private FrameworkElement findItemElement(IExpanderDataItem item, List <FrameworkElement> elementsList)
        {
            FrameworkElement elem = null;

            foreach (FrameworkElement fe in elementsList)
            {
                if (item.Equals(fe.DataContext))
                {
                    elem = fe;
                    break;
                }
            }

            return(elem);
        }
コード例 #4
0
        private ContentControl findItemContentWrapperOfItem(IExpanderDataItem item)
        {
            ContentControl elem = null;

            foreach (ContentControl fe in itemContentWrappersList)
            {
                if (item.Equals(fe.DataContext))
                {
                    elem = fe;
                    break;
                }
            }

            return(elem);
        }