乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      MeasureOverride 和ArrangeOverride 淺理解

       昵稱11482448 2013-04-28


      時(shí)間:2011-01-09 07:43來源:博客園 作者:xiaokang088 點(diǎn)擊:796次
      public class CustomControl1:Panel { ///summary ///先測(cè)量需要多大尺寸,做個(gè)申報(bào)準(zhǔn)備 ////summary ///paramname=constraint限定的尺寸,比如,規(guī)定了width和height/param ///returns/returns protected override SizeMeasureOverride(Sizeconstraint) { //定義預(yù)期的寬度和高度 double height=0,width=0; UIElemen
        
       public class CustomControl1 : Panel
          {
              /// <summary>
              /// 先測(cè)量需要多大尺寸,做個(gè)申報(bào)準(zhǔn)備
              /// </summary>
              /// <param name="constraint">限定的尺寸,比如,規(guī)定了width和height</param>
              /// <returns></returns>
              protected override Size MeasureOverride(Size constraint)
              {
                  //定義預(yù)期的寬度和高度
                  double height = 0, width = 0;
                  UIElement element;
                  //遍歷每個(gè)元素,計(jì)算所需的總尺寸
                  for (int i = 0; i < Children.Count; i++)
                  {
                      element = Children[i];
                      //按照限定的尺寸測(cè)量一下自己,拿鏡子找著自己
                      element.Measure(constraint);
                      if (height < element.DesiredSize.Height)
                          height = element.DesiredSize.Height;
                      width += element.DesiredSize.Width;
                  }
                  //申報(bào),我需要這個(gè)尺寸
                  return new Size(width, height);
              }
             
              /// <summary>
              /// 排列每個(gè)元素
              /// </summary>
              /// <param name="arrangeBounds">測(cè)量的尺寸</param>
              /// <returns></returns>
              protected override Size ArrangeOverride(Size arrangeBounds)
              {
                  double currentX = 100;
                  UIElement element;
                  for (int i = 0; i < Children.Count; i++)
                  {
                      element = Children[i];
                      //排列每個(gè)元素
                      Children[i].Arrange(new Rect(currentX, 0, element.DesiredSize.Width, element.DesiredSize.Height));
                      currentX += element.DesiredSize.Width;
                  }
                  return arrangeBounds;
              }
          }

       <local:CustomControl1  Width="300" Background="Gray" HorizontalAlignment="Right" Margin="0,20,151,280">
                  <Rectangle Width="100" Height="50" Fill="Red" Margin="10,10,0,0" />
                  <Rectangle Width="100" Height="50" Fill="Yellow" Margin="10,10,0,0" />
                  <Rectangle Width="100" Height="50" Fill="Green" Margin="10,10,0,0" />
              </local:CustomControl1>
        

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多