本文整理汇总了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);
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}