zoukankan      html  css  js  c++  java
  • WP7备注(22)(多类型Panel自定义)

    单Cell的Grid自定义

    namespace SingleCellGridDemo
    {
    public class SingleCellGrid : Panel
    {
    protected override Size MeasureOverride(Size availableSize)
    {
    Size compositeSize = new Size();
    foreach (UIElement child in Children)
    {
    child.Measure(availableSize);
    compositeSize.Width = Math.Max(compositeSize.Width,
    child.DesiredSize.Width);
    compositeSize.Height = Math.Max(compositeSize.Height,
    child.DesiredSize.Height);
    }
    return compositeSize;
    }
    protected override Size ArrangeOverride(Size finalSize)
    {
    foreach (UIElement child in Children)
    {
    child.Arrange(new Rect(new Point(), finalSize));
    }
    return base.ArrangeOverride(finalSize);
    }
    }
    }

    Vertical StackPanel自定义:

    protected override Size MeasureOverride(Size availableSize)
    {
    Size compositeSize = new Size();
    foreach (UIElement child in Children)
    {
    child.Measure(new Size(availableSize.Width, Double.PositiveInfinity));
    compositeSize.Width = Math.Max(compositeSize.Width,
    child.DesiredSize.Width);
    compositeSize.Height += child.DesiredSize.Height;
    }
    return compositeSize;
    }
    
    protected override Size ArrangeOverride(Size finalSize)
    {
    double x = 0, y = 0;
    foreach (UIElement child in Children)
    {
    child.Arrange(new Rect(x, y, finalSize.Width, child.DesiredSize.Height));
    y += child.DesiredSize.Height;
    }
    return base.ArrangeOverride(finalSize);
    }
  • 相关阅读:
    CentOS 7 虚拟机的安装
    2 MySQL rpm
    01-在实体类上加了lombok的@Data注解
    02-myBatisPlus的wrapper接口的使用
    2 MySQL rpm 安装 --下载
    1-MySQL介绍
    MySQL的不归路
    电脑型号4 1500 内存大 机械大硬盘
    电脑型号3 1200 大硬盘
    电脑概览 2 1200 固态SSD
  • 原文地址:https://www.cnblogs.com/otomii/p/2032569.html
Copyright © 2011-2022 走看看