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);
    }
  • 相关阅读:
    Mysql多实例
    nginx不间断服务平滑升级
    源码编译安装mysql
    nginx优化后的主配置文件
    Nginx安装与应用
    Android 7 修改启动动画和开机声音
    Android 7 默认声音/大小修改
    高通与At指令:ATFWD解析
    高通与At指令:AtCop解析
    高通与At指令:基础概念
  • 原文地址:https://www.cnblogs.com/otomii/p/2032569.html
Copyright © 2011-2022 走看看