本文整理汇总了C#中Xamarin.Forms.BoxView类的典型用法代码示例。如果您正苦于以下问题:C# BoxView类的具体用法?C# BoxView怎么用?C# BoxView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoxView类属于Xamarin.Forms命名空间,在下文中一共展示了BoxView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MainPageCS
public MainPageCS ()
{
ItemTemplate = new DataTemplate (() => {
var nameLabel = new Label {
FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
nameLabel.SetBinding (Label.TextProperty, "Name");
var colorBoxView = new BoxView {
WidthRequest = 200,
HeightRequest = 200,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
colorBoxView.SetBinding (BoxView.ColorProperty, "Color");
return new ContentPage {
Padding = new Thickness (0, Device.OnPlatform (40, 40, 0), 0, 0),
Content = new StackLayout {
Children = {
nameLabel,
colorBoxView
}
}
};
});
ItemsSource = ColorsDataModel.All;
}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:30,代码来源:MainPageCS.cs
示例2: TealTemplate
public TealTemplate ()
{
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.1, GridUnitType.Star) });
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.8, GridUnitType.Star) });
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.1, GridUnitType.Star) });
ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (0.05, GridUnitType.Star) });
ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (0.95, GridUnitType.Star) });
var topBoxView = new BoxView { Color = Color.Teal };
Children.Add (topBoxView, 0, 0);
Grid.SetColumnSpan (topBoxView, 2);
var topLabel = new Label {
TextColor = Color.White,
VerticalOptions = LayoutOptions.Center
};
topLabel.SetBinding (Label.TextProperty, new TemplateBinding ("Parent.HeaderText"));
Children.Add (topLabel, 1, 0);
var contentPresenter = new ContentPresenter ();
Children.Add (contentPresenter, 0, 1);
Grid.SetColumnSpan (contentPresenter, 2);
var bottomBoxView = new BoxView { Color = Color.Teal };
Children.Add (bottomBoxView, 0, 2);
Grid.SetColumnSpan (bottomBoxView, 2);
var bottomLabel = new Label {
TextColor = Color.White,
VerticalOptions = LayoutOptions.Center
};
bottomLabel.SetBinding (Label.TextProperty, new TemplateBinding ("Parent.FooterText"));
Children.Add (bottomLabel, 1, 2);
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:34,代码来源:HomePageCS.cs
示例3: BoxViewDemoPage
public BoxViewDemoPage()
{
Label header = new Label
{
Text = "BoxView",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
};
BoxView boxView = new BoxView
{
Color = Color.Accent,
WidthRequest = 150,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
boxView
}
};
}
开发者ID:Biotelligent,项目名称:xamarin-forms-samples,代码行数:31,代码来源:BoxViewDemoPage.cs
示例4: StackLayoutDemoCode
public StackLayoutDemoCode ()
{
Title = "StackLayout Demo - C#";
layout = new StackLayout { Spacing = 0 };
StackChangeButton = new Button {
Text = "Spacing: 0",
FontSize = 20,
VerticalOptions = LayoutOptions.Start,
HorizontalOptions = LayoutOptions.FillAndExpand
};
StackChangeButton.Clicked += StackChangeButton_Clicked;
BoxView yellowBox = new BoxView {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Color = Color.Yellow
};
BoxView greenBox = new BoxView {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Color = Color.Green
};
BoxView blueBox = new BoxView {
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.FillAndExpand,
Color = Color.Blue,
HeightRequest = 75
};
layout.Children.Add (StackChangeButton);
layout.Children.Add (yellowBox);
layout.Children.Add (greenBox);
layout.Children.Add (blueBox);
Content = layout;
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:33,代码来源:StackLayoutDemoCode.cs
示例5: AquaTemplate
public AquaTemplate()
{
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.1, GridUnitType.Star) });
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.8, GridUnitType.Star) });
RowDefinitions.Add (new RowDefinition { Height = new GridLength (0.1, GridUnitType.Star) });
ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (0.05, GridUnitType.Star) });
ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (0.95, GridUnitType.Star) });
var topBoxView = new BoxView { Color = Color.Aqua };
Children.Add (topBoxView, 0, 0);
Grid.SetColumnSpan (topBoxView, 2);
var topLabel = new Label {
Text = "Control Template Demo App",
TextColor = Color.Blue,
VerticalOptions = LayoutOptions.Center
};
Children.Add (topLabel, 1, 0);
var contentPresenter = new ContentPresenter ();
Children.Add (contentPresenter, 0, 1);
Grid.SetColumnSpan (contentPresenter, 2);
var bottomBoxView = new BoxView { Color = Color.Aqua };
Children.Add (bottomBoxView, 0, 2);
Grid.SetColumnSpan (bottomBoxView, 2);
var bottomLabel = new Label {
Text = "(c) Xamarin 2016",
TextColor = Color.Blue,
VerticalOptions = LayoutOptions.Center
};
Children.Add (bottomLabel, 1, 2);
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:34,代码来源:HomePageCS.cs
示例6: ChessboardDynamicPage
public ChessboardDynamicPage()
{
absoluteLayout = new AbsoluteLayout
{
BackgroundColor = Color.FromRgb(240, 220, 130),
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
for (int i = 0; i < 32; i++)
{
BoxView boxView = new BoxView
{
Color = Color.FromRgb(0, 64, 0)
};
absoluteLayout.Children.Add(boxView);
}
ContentView contentView = new ContentView
{
Content = absoluteLayout
};
contentView.SizeChanged += OnContentViewSizeChanged;
this.Padding = new Thickness(5, Device.OnPlatform(25, 5, 5), 5, 5);
this.Content = contentView;
}
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:27,代码来源:ChessboardDynamicPage.cs
示例7: BoxViewDemoPage
//View
public BoxViewDemoPage()
{
var heading = new Label
{
Text = "BoxView",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.StartAndExpand,
FontSize = 50,
FontAttributes = FontAttributes.Bold | FontAttributes.Italic
};
var boxView = new BoxView
{
Color = Color.Red,
WidthRequest = 150,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
var mainLayout = new StackLayout
{
Children =
{
heading,
boxView
}
};
Content = mainLayout;
}
开发者ID:theaspiringitpro,项目名称:Xamarin-Portfolio,代码行数:32,代码来源:BoxViewDemoPage.cs
示例8: OrderListHeaderView
public OrderListHeaderView()
{
HeightRequest = Sizes.LargeRowHeight;
#region add new order image
AddNewOrderImage = new Image()
{
Aspect = Aspect.AspectFit
};
Device.OnPlatform(
iOS: () => AddNewOrderImage.Source = new FileImageSource(){ File = "add_ios_blue" },
Android: () => AddNewOrderImage.Source = new FileImageSource() { File = "add_android_blue" }
);
AddNewOrderImage.IsVisible = Device.OS != TargetPlatform.Android;
#endregion
#region add new order label
AddNewOrderTextLabel = new Label
{
Text = TextResources.Customers_Orders_NewOrder.ToUpper(),
TextColor = Palette._004,
XAlign = TextAlignment.Start,
YAlign = TextAlignment.Center,
};
#endregion
#region compose view hierarchy
BoxView bottomBorder = new BoxView() { BackgroundColor = Palette._013, HeightRequest = 1 };
const double imagePaddingPercent = .35;
RelativeLayout relativeLayout = new RelativeLayout();
relativeLayout.Children.Add(
view: AddNewOrderImage,
yConstraint: Constraint.RelativeToParent(parent => parent.Height * imagePaddingPercent),
xConstraint: Constraint.RelativeToParent(parent => parent.Height * imagePaddingPercent),
widthConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)),
heightConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)));
relativeLayout.Children.Add(
view: AddNewOrderTextLabel,
xConstraint: Constraint.RelativeToView(AddNewOrderImage, (parent, view) => view.X + (view.Width / 2) + parent.Height * imagePaddingPercent),
widthConstraint: Constraint.RelativeToView(AddNewOrderImage, (parent, view) => parent.Width - view.Width),
heightConstraint: Constraint.RelativeToParent(parent => parent.Height)
);
relativeLayout.Children.Add(
view: bottomBorder,
yConstraint: Constraint.RelativeToParent(parent => parent.Height - 1),
widthConstraint: Constraint.RelativeToParent(parent => parent.Width),
heightConstraint: Constraint.Constant(1)
);
#endregion
Content = relativeLayout;
}
开发者ID:rsaggio,项目名称:app-crm,代码行数:60,代码来源:OrderListHeaderView.cs
示例9: AbsoluteLayoutExplorationCode
public AbsoluteLayoutExplorationCode ()
{
Title = "Absolute Layout Exploration - C#";
var layout = new AbsoluteLayout();
var centerLabel = new Label {Text = "I'm centered on iPhone 4 but no other device.", LineBreakMode = LineBreakMode.WordWrap, FontSize = 20};
AbsoluteLayout.SetLayoutBounds (centerLabel, new Rectangle (115, 159, 100, 100));
// it is not necessary to set layout flags because absolute positioning is the default
var bottomLabel = new Label { Text = "I'm bottom center on every device.", LineBreakMode = LineBreakMode.WordWrap };
AbsoluteLayout.SetLayoutBounds (bottomLabel, new Rectangle (.5, 1, .5, .1));
AbsoluteLayout.SetLayoutFlags (bottomLabel, AbsoluteLayoutFlags.All);
var rightBox = new BoxView{ Color = Color.Olive };
AbsoluteLayout.SetLayoutBounds (rightBox, new Rectangle (1, .5, 25, 100));
AbsoluteLayout.SetLayoutFlags (rightBox, AbsoluteLayoutFlags.PositionProportional);
var leftBox = new BoxView{ Color = Color.Red };
AbsoluteLayout.SetLayoutBounds (leftBox, new Rectangle (0, .5, 25, 100));
AbsoluteLayout.SetLayoutFlags (leftBox, AbsoluteLayoutFlags.PositionProportional);
var topBox = new BoxView{ Color = Color.Blue };
AbsoluteLayout.SetLayoutBounds (topBox, new Rectangle (.5, 0, 100, 25));
AbsoluteLayout.SetLayoutFlags (topBox, AbsoluteLayoutFlags.PositionProportional);
layout.Children.Add (bottomLabel);
layout.Children.Add (centerLabel);
layout.Children.Add (rightBox);
layout.Children.Add (leftBox);
layout.Children.Add (topBox);
Content = layout;
}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:34,代码来源:AbsoluteLayoutExplorationCode.cs
示例10: RelativeLayoutDemoCode
public RelativeLayoutDemoCode ()
{
Title = "Relative Layout Demo - C#";
outerLayout = new AbsoluteLayout ();
layout = new RelativeLayout ();
centerLabel = new Label { FontSize = 20, Text = "RelativeLayout Demo"};
buttonLayout = new AbsoluteLayout ();
box = new BoxView { Color = Color.Blue, HeightRequest = 50, WidthRequest = 50 };
layout.Children.Add (box, Constraint.RelativeToParent ((parent) => {
return (parent.Width * .5) - 50;
}), Constraint.RelativeToParent ((parent) => {
return (parent.Height * .1) - 50;
}));
layout.Children.Add (centerLabel, Constraint.RelativeToParent ((parent) => {
return (parent.Width * .5) - 50;
}), Constraint.RelativeToParent ((parent) => {
return (parent.Height * .5) - 50;
}));
moveButton = new Button { BackgroundColor = Color.White, FontSize = 20, TextColor = Color.Lime, Text = "Move", BorderRadius = 0};
buttonLayout.Children.Add (moveButton, new Rectangle(0,1,1,1), AbsoluteLayoutFlags.All);
outerLayout.Children.Add (layout, new Rectangle(0,0,1,1), AbsoluteLayoutFlags.All);
outerLayout.Children.Add (buttonLayout, new Rectangle(0,1,1,50), AbsoluteLayoutFlags.PositionProportional|AbsoluteLayoutFlags.WidthProportional);
moveButton.Clicked += MoveButton_Clicked;
x = 0f;
y = 0f;
Content = outerLayout;
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:28,代码来源:RelativeLayoutDemoCode.cs
示例11: BoxViewDemoPage
public BoxViewDemoPage()
{
Label header = new Label
{
Text = "BoxView",
Font = Font.SystemFontOfSize(50, FontAttributes.Bold),
HorizontalOptions = LayoutOptions.Center
};
BoxView boxView = new BoxView
{
Color = Color.Accent,
WidthRequest = 150,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
boxView
}
};
}
开发者ID:nrogoff,项目名称:xamarin-forms-samples,代码行数:28,代码来源:BoxViewDemoPage.cs
示例12: TaskItemCell
public TaskItemCell ()
{
var label = new Label {
YAlign = TextAlignment.Center
};
var stripe = new BoxView {
Color = Color.Red
};
label.SetBinding (Label.TextProperty, new Binding ("Name"));
stripe.SetBinding (BoxView.IsVisibleProperty, new Binding ("Completed"));
var layout = new RelativeLayout {
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.StartAndExpand
};
layout.Children.Add (
label,
Constraint.RelativeToParent (p => 20),
Constraint.RelativeToParent (p => 0),
Constraint.RelativeToParent (p => p.Width - 40),
Constraint.RelativeToParent (p => p.Height));
layout.Children.Add (
stripe,
Constraint.RelativeToParent (p => 10),
Constraint.RelativeToParent (p => (p.Height / 2) - 1),
Constraint.RelativeToParent (p => p.Width - 20),
Constraint.RelativeToParent (p => 2));
View = layout;
}
开发者ID:RomeroAlesander,项目名称:DC-Encyclopedia-Android,代码行数:29,代码来源:TaskItemCell.cs
示例13: GridBarChartPage
public GridBarChartPage()
{
InitializeComponent();
List<View> views = new List<View>();
TapGestureRecognizer tapGesture = new TapGestureRecognizer();
tapGesture.Tapped += OnBoxViewTapped;
// Create BoxView elements and add to List.
for (int i = 0; i < COUNT; i++)
{
BoxView boxView = new BoxView
{
Color = Color.Accent,
HeightRequest = 300 * random.NextDouble(),
VerticalOptions = LayoutOptions.End,
StyleId = RandomNameGenerator()
};
boxView.GestureRecognizers.Add(tapGesture);
views.Add(boxView);
}
// Add whole List of BoxView elements to Grid.
grid.Children.AddHorizontal(views);
// Start a timer at the frame rate.
Device.StartTimer(TimeSpan.FromMilliseconds(15), OnTimerTick);
}
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:28,代码来源:GridBarChartPage.xaml.cs
示例14: NetworkStatusPage
public NetworkStatusPage()
{
var networkLabel = new Label {
Text = "Network Status",
YAlign = TextAlignment.Center
};
var networkBox = new BoxView {
Color = Color.White,
HeightRequest = 25,
WidthRequest = 25
};
var networkStack = new StackLayout {
Orientation = StackOrientation.Horizontal,
Padding = 15,
Spacing = 25,
Children = { networkLabel, networkBox }
};
var button = new Button {
Text = "Update Status",
HorizontalOptions = LayoutOptions.FillAndExpand
};
button.Clicked += (sender, e) => {
var service = DependencyService.Get<INetworkService>();
var isConnected = service.IsConnected();
networkBox.Color = isConnected ? Color.Green : Color.Red;
};
Content = new StackLayout {
Children = { networkStack, button }
};
}
开发者ID:ardiprakasa,项目名称:create-cross-platform-mobile-apps-with-xamarinforms,代码行数:35,代码来源:NetworkStatusPage.cs
示例15: ClockPage
public ClockPage()
{
AbsoluteLayout absoluteLayout = new AbsoluteLayout();
for (int i = 0; i < tickMarks.Length; i++)
{
tickMarks[i] = new BoxView
{
Color = Color.Accent
};
absoluteLayout.Children.Add(tickMarks[i]);
}
absoluteLayout.Children.Add(hourHand =
new BoxView
{
Color = Color.Accent
});
absoluteLayout.Children.Add(minuteHand =
new BoxView
{
Color = Color.Accent
});
absoluteLayout.Children.Add(secondHand =
new BoxView
{
Color = Color.Red
});
Content = absoluteLayout;
Device.StartTimer(TimeSpan.FromMilliseconds(16), OnTimerTick);
SizeChanged += OnPageSizeChanged;
}
开发者ID:dimgrek,项目名称:AnalogClockXamarin,代码行数:34,代码来源:ClockPage.cs
示例16: App
public App()
{
_grid = new Grid {
BackgroundColor = Color.Purple, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
};
// THIS BOX VIEW DOES NOT SHOW UP IF YOU RE-SIZE THE ROW DEFINITION
var boxView = new BoxView { BackgroundColor = Color.Blue, VerticalOptions = LayoutOptions.End };
var button = new Button
{
Text = "button",
BackgroundColor = Color.Lime,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
button.Clicked += (sender, e) =>
{
_grid.RowDefinitions[1].Height = Math.Abs(_grid.RowDefinitions[1].Height.Value - 100) < double.Epsilon ?
new GridLength(0) : new GridLength(100);
};
Grid.SetRow(boxView, 1);
_grid.RowDefinitions.Add(new RowDefinition() { Height = 100 });
_grid.RowDefinitions.Add(new RowDefinition() { Height = 0 }); // CHANGE THIS TO 100 and it works fine
_grid.Children.Add(boxView);
_grid.Children.Add(button);
MainPage = new ContentPage { Content = _grid };
}
开发者ID:shanempope,项目名称:BoxViewGridRowIssue,代码行数:33,代码来源:BoxViewGridIssue.cs
示例17: ChessboardFixed
public ChessboardFixed()
{
const double squareSize = 35;
AbsoluteLayout absoluteLayout = new AbsoluteLayout
{
BackgroundColor = Color.FromRgb(240, 220, 130),
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
for (int row = 0; row < 8; row++)
{
for (int col = 0; col < 8; col++)
{
//Skip every other square.
if (((row ^ col) & 1) == 0)
continue;
BoxView boxView = new BoxView
{
Color = Color.FromRgb(0, 64, 0)
};
Rectangle rect = new Rectangle(col * squareSize,
row * squareSize,
squareSize, squareSize);
absoluteLayout.Children.Add(boxView, rect);
}
}
this.Content = absoluteLayout;
}
开发者ID:tambama,项目名称:XamarinPreviewBook,代码行数:34,代码来源:ChessboardFixed.cs
示例18: PanGestureExample3
public PanGestureExample3 ()
{
InitializeComponent ();
MainLayout.OnLayoutChildren += MainLayout_OnLayoutChildren;
OuterView = new StackLayout {
Padding = new Thickness (50),
BackgroundColor = Color.Yellow
};
this.MainLayout.Children.Add (OuterView);
OuterView.Layout (_outerLayoutBounds);
Box = new BoxView {
Color = Color.Red,
WidthRequest = 150,
HeightRequest = 150,
};
OuterView.Children.Add (Box);
var panRecognizer = new PanGestureRecognizer ();
panRecognizer.IsConsumingTouchesInParallel = true;
panRecognizer.OnAction += Gesture_OnAction;
Box.AddGestureRecognizer (panRecognizer);
Box2 = new BoxView ();
Box2.Color = Color.Blue;
this.MainLayout.Children.Add (Box2);
Box2.Layout (_box2Bounds);
panRecognizer = new PanGestureRecognizer ();
panRecognizer.OnAction += Gesture_OnAction;
panRecognizer.IsConsumingTouchesInParallel = true;
Box2.AddGestureRecognizer (panRecognizer);
DoBoxAnimation ();
}
开发者ID:patridge,项目名称:TwinTechsFormsLib,代码行数:34,代码来源:PanGestureExample3.xaml.cs
示例19: CardStatusView
public CardStatusView (Card card)
{
var statusBoxView = new BoxView {
VerticalOptions = LayoutOptions.Fill,
HorizontalOptions = LayoutOptions.Fill
};
switch (card.Status) {
case CardStatus.Alert:
statusBoxView.BackgroundColor = StyleKit.Status.AlertColor;
break;
case CardStatus.Completed:
statusBoxView.BackgroundColor = StyleKit.Status.CompletedColor;
break;
case CardStatus.Unresolved:
statusBoxView.BackgroundColor = StyleKit.Status.UnresolvedColor;
break;
default:
statusBoxView.BackgroundColor = StyleKit.Status.UnresolvedColor;
break;
}
;
Content = statusBoxView;
}
开发者ID:Sway0308,项目名称:Xamarin-Forms-InAnger,代码行数:25,代码来源:CardStatusView.cs
示例20: InitializeComponent
private void InitializeComponent()
{
this.LoadFromXaml(typeof(TItleView));
boxView = this.FindByName<BoxView>("boxView");
colorNameLabel = this.FindByName<Label>("colorNameLabel");
colorValueLabel = this.FindByName<Label>("colorValueLabel");
}
开发者ID:zinx2,项目名称:TTViewWorkspace,代码行数:7,代码来源:TㅑtleView.xaml.g.cs
注:本文中的Xamarin.Forms.BoxView类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论