Example #1
0
        private static void SetActive(FluidGridViewTriggerCollection triggers)
        {
            if (triggers.Owner.ItemsPanelRoot == null)
            {
                return;
            }

            var owner     = triggers.Owner;
            var reference = GetReference(owner);

            var paddingNear = reference.Orientation == Orientation.Horizontal
                ? owner.Padding.Left
                : owner.Padding.Top;

            var paddingFar = reference.Orientation == Orientation.Horizontal
                ? owner.Padding.Right
                : owner.Padding.Bottom;

            var parentLength = reference.Orientation == Orientation.Horizontal
                ? owner.ItemsPanelRoot.ActualWidth
                : owner.ItemsPanelRoot.ActualHeight;

            FluidGridViewTriggerBase trigger = null;

            foreach (var child in triggers)
            {
                if (child.MaybeActive(parentLength))
                {
                    trigger = child;
                }
            }

            if (trigger != null)
            {
                //var itemLength = trigger.GetItemLength(parentLength - paddingNear - paddingFar);
                var itemLength = trigger.GetItemLength(parentLength);

                if (reference.Orientation == Orientation.Horizontal)
                {
                    reference.ItemWidth = itemLength;
                }
                else
                {
                    reference.ItemHeight = itemLength;
                }

                var orientationOnly = GetOrientationOnly(owner);
                if (!orientationOnly)
                {
                    if (reference.Orientation == Orientation.Horizontal)
                    {
                        reference.ItemHeight = itemLength;
                    }
                    else
                    {
                        reference.ItemWidth = itemLength;
                    }
                }
            }
        }
Example #2
0
        private static void SetActive(FluidGridViewTriggerCollection triggers, WrapGridReference reference)
        {
            if (triggers.Owner.ItemsPanelRoot == null || reference == null)
            {
                return;
            }

            var owner = triggers.Owner;

            //var paddingNear = reference.Orientation == Orientation.Horizontal
            //    ? owner.Padding.Left
            //    : owner.Padding.Top;

            //var paddingFar = reference.Orientation == Orientation.Horizontal
            //    ? owner.Padding.Right
            //    : owner.Padding.Bottom;

            var parentLength = reference.Orientation == Orientation.Horizontal
                ? owner.ItemsPanelRoot.ActualWidth
                : owner.ItemsPanelRoot.ActualHeight;

            FluidGridViewTriggerBase trigger = null;

            foreach (var child in triggers)
            {
                if (child.MaybeActive(parentLength))
                {
                    trigger = child;
                }
            }

            if (trigger != null)
            {
                var maxLength = GetMaxLength(owner);
                if (parentLength > maxLength && !double.IsNaN(maxLength))
                {
                    parentLength = maxLength;
                }

                //var itemLength = trigger.GetItemLength(parentLength - paddingNear - paddingFar);
                var itemLength = trigger.GetItemLength(Math.Floor(parentLength), out int maximumRowsOrColumns);

                reference.MaximumRowsOrColumns = maximumRowsOrColumns;

                if (reference.Orientation == Orientation.Horizontal)
                {
                    reference.ItemWidth = itemLength;
                }
                else
                {
                    reference.ItemHeight = itemLength;
                }

                var orientationOnly = GetOrientationOnly(owner);
                if (!orientationOnly)
                {
                    if (reference.Orientation == Orientation.Horizontal)
                    {
                        reference.ItemHeight = itemLength;
                    }
                    else
                    {
                        reference.ItemWidth = itemLength;
                    }
                }
            }
        }