当前位置: 首页>>代码示例>>C#>>正文


C# View.GetSizeRequest方法代码示例

本文整理汇总了C#中View.GetSizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetSizeRequest方法的具体用法?C# View.GetSizeRequest怎么用?C# View.GetSizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在View的用法示例。


在下文中一共展示了View.GetSizeRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestPreferredSize

		public void TestPreferredSize ()
		{
			View view = new View {
				IsPlatformEnabled = true,
				Platform = new UnitPlatform ()
			};

			bool fired = false;
			view.MeasureInvalidated += (sender, e) => fired = true;

			view.WidthRequest = 200;
			view.HeightRequest = 300;

			Assert.True (fired);

			var result = view.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity).Request;
			Assert.AreEqual (new Size (200, 300), result);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:18,代码来源:ViewUnitTests.cs

示例2: ShowTopNoti

        public void ShowTopNoti(Xamarin.Forms.Page p, View noti, int msTTL = 1500)
        {
            var render = Convert(noti, p);

            if (render != null)
            {
                var nanchor = p.GetRenderer() as Canvas;
                p.WidthRequest = nanchor.ActualWidth - 10;

                if (noti.HeightRequest <= 0)
                {
                    var size = noti.GetSizeRequest(nanchor.ActualWidth - 10, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height > XFPopupConst.SCREEN_HEIGHT / 2)
                    {
                        noti.HeightRequest = XFPopupConst.SCREEN_HEIGHT / 2;
                    }
                    else
                    {
                        noti.HeightRequest = size.Request.Height;
                    }
                }

                noti.Layout(new Rectangle(0, 0, noti.WidthRequest, noti.HeightRequest));

                var nativePopup = new System.Windows.Controls.Primitives.Popup();
                nativePopup.VerticalOffset = 0;
                nativePopup.HorizontalOffset = 0;

                var boder = new Border();
                boder.BorderThickness = new System.Windows.Thickness(1);
                boder.Padding = new System.Windows.Thickness(5);
                boder.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 50, 50, 50));
                boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));

                boder.VerticalAlignment = VerticalAlignment.Top;
                boder.HorizontalAlignment = HorizontalAlignment.Stretch;

                boder.Width = noti.WidthRequest + 10;
                boder.Height = noti.HeightRequest + 10;
                boder.CornerRadius = new CornerRadius(5);

                var elm = (render as Panel);
                elm.VerticalAlignment = VerticalAlignment.Top;
                elm.HorizontalAlignment = HorizontalAlignment.Left;
                boder.Child = elm;

                nativePopup.Child = boder;
                nativePopup.IsOpen = true;

                //
                byte count = 0;
                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick += (object sender, EventArgs e) => {
                    count++;
                    if (count >= 10) {
                        dispatcherTimer.Stop();
                        nativePopup.IsOpen = false;

                    }

                    boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(255 - count * 25), 255, 255, 255));
                };

                dispatcherTimer.Interval = new TimeSpan(0, 0, 0,msTTL/10);
                dispatcherTimer.Start();
            }
        }
开发者ID:thaihung203,项目名称:xfpopup,代码行数:67,代码来源:WPXFPopupSrvc.cs

示例3: CreateDropDown

        public IXFPopupCtrl CreateDropDown(View anchor, View drop)
        {
            CustomDropDown dlg = null;

            var render = Convert(drop, anchor);

            if (render != null)
            {
                var nanchor = anchor.GetRenderer() as Canvas;
                drop.WidthRequest = nanchor.ActualWidth;

                if (drop.HeightRequest <= 0)
                {
                    var size = drop.GetSizeRequest(nanchor.ActualWidth, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height > XFPopupConst.SCREEN_HEIGHT / 2)
                    {
                        drop.HeightRequest = XFPopupConst.SCREEN_HEIGHT / 2;
                    }
                    else
                    {
                        drop.HeightRequest = size.Request.Height;
                    }
                }

                drop.Layout(new Rectangle(0, 0, drop.WidthRequest, drop.HeightRequest));

                dlg = new CustomDropDown(nanchor, render as Canvas, drop.HeightRequest);
            }

            return dlg;
        }
开发者ID:thaihung203,项目名称:xfpopup,代码行数:31,代码来源:WPXFPopupSrvc.cs

示例4: HeightRequestEffectsGetSizeRequest

		public void HeightRequestEffectsGetSizeRequest ()
		{
			var view = new View ();
			view.IsPlatformEnabled = true;
			view.Platform = new UnitPlatform ((ve, widthConstraint, heightConstraint) => {
				if (heightConstraint < 30)
					return new SizeRequest (new Size (40, 50));
				return new SizeRequest(new Size(20, 100));
			});

			view.HeightRequest = 20;
			var request = view.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity);

			Assert.AreEqual (new Size (40, 20), request.Request);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:15,代码来源:ViewUnitTests.cs

示例5: MinimumHeightRequestInSizeRequest

		public void MinimumHeightRequestInSizeRequest ()
		{
			var view = new View {
				Platform = new UnitPlatform (),
				IsPlatformEnabled = true
			};

			view.HeightRequest = 200;
			view.WidthRequest = 20;
			view.MinimumHeightRequest = 100;

			var result = view.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity);
			Assert.AreEqual (new Size (20, 200), result.Request);
			Assert.AreEqual (new Size (20, 100), result.Minimum);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:15,代码来源:ViewUnitTests.cs


注:本文中的View.GetSizeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。