首页 > 其他 > 详细

uwp通用应用重写列表面板控件

时间:2018-05-21 00:26:11      阅读:185      评论:0      收藏:0      [点我收藏+]

MyPanel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;

namespace App1
{
    public class MyPanel : Panel
    {
        protected override Size MeasureOverride(Size availableSize)
        {
            if (Children.Count > 0)
            {
                double yy = 0d;
                double ww = 0d;
                foreach (var u in Children)
                {
                    u.Measure(availableSize);
                    Size dssize = u.DesiredSize;
                    yy += dssize.Height;
                    ww = dssize.Width > ww ? dssize.Width : ww;
                }
                return new Size(ww, yy);
            }
            return availableSize;
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            double y = 0d;
            foreach (var u in Children)
            {
                u.Arrange(new Rect(0d, y, u.DesiredSize.Width, u.DesiredSize.Height));
                y += u.DesiredSize.Height;
            }
            return finalSize;
        }
    }
}

 

uwp通用应用重写列表面板控件

原文:https://www.cnblogs.com/maoriaty/p/9065247.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!