本文整理汇总了C#中Xamarin.Forms.ContentView.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ContentView.SetBinding方法的具体用法?C# ContentView.SetBinding怎么用?C# ContentView.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.ContentView
的用法示例。
在下文中一共展示了ContentView.SetBinding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomerOrderListViewGroupHeaderCell
public CustomerOrderListViewGroupHeaderCell()
{
var title = new Label
{
FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))),
TextColor = Color.White,
VerticalOptions = LayoutOptions.Center,
FontAttributes = FontAttributes.Bold
};
title.SetBinding(Label.TextProperty, "Key");
var contentView = new ContentView() { Content = title, HeightRequest = Sizes.MediumRowHeight, Padding = new Thickness(10, 0) };
contentView.SetBinding(StackLayout.BackgroundColorProperty, "Key", converter: new OrderListHeaderViewBackgroudColorConverter());
View = contentView;
}
示例2: Init
//.........这里部分代码省略.........
}),
Constraint.RelativeToParent((parent) => {
return wButton;
})
);
relativeLayout.Children.Add(btnBack,
Constraint.RelativeToParent((parent) => {
return 0;
}),
Constraint.RelativeToParent((parent) => {
return statusBarHeight;
}),
Constraint.RelativeToParent((parent) => {
return wButton;
}),
Constraint.RelativeToParent((parent) => {
return wButton;
})
);
relativeLayout.Children.Add(btnAction,
Constraint.RelativeToParent((parent) => {
return parent.Width - wButton * 2;
}),
Constraint.RelativeToParent((parent) => {
return statusBarHeight;
}),
Constraint.RelativeToParent((parent) => {
return wButton * 2;
}),
Constraint.RelativeToParent((parent) => {
return wButton;
})
);
relativeLayout.Children.Add(btnSave,
Constraint.RelativeToParent((parent) => {
return parent.Width - wButton * 2;
}),
Constraint.RelativeToParent((parent) => {
return statusBarHeight;
}),
Constraint.RelativeToParent((parent) => {
return wButton * 2;
}),
Constraint.RelativeToParent((parent) => {
return wButton;
})
);
relativeLayout.Children.Add(lblTitle,
Constraint.RelativeToParent((parent) => {
return 10;
}),
Constraint.RelativeToParent((parent) => {
return pTestata;
}),
Constraint.RelativeToParent((parent) => {
return parent.Width - 20;
}),
Constraint.RelativeToParent((parent) => {
return hLblTitle;
})
);
abs = new AbsoluteLayout();
AbsoluteLayout.SetLayoutFlags(relativeLayout, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(relativeLayout, new Rectangle(0, 0, 1, 1));
abs.Children.Add(relativeLayout);
//****ACTIVITY INDICATOR*******//
#region activityIndicator
var backIndicator = new ContentView();
backIndicator.BackgroundColor = Color.Black;
backIndicator.IsVisible = IsLoading;
backIndicator.Opacity = 0.5;
backIndicator.BindingContext = this;
backIndicator.SetBinding(ContentView.IsVisibleProperty, "IsLoading");
AbsoluteLayout.SetLayoutFlags(backIndicator, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(backIndicator, new Rectangle(0, 0, 1, 1));
abs.Children.Add(backIndicator);
var actIndicator = new ActivityIndicator();
actIndicator.IsVisible = IsLoading;
actIndicator.IsRunning = IsLoading;
actIndicator.BindingContext = this;
actIndicator.BackgroundColor = Color.Transparent;
actIndicator.Color = Color.White;
actIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading");
actIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
AbsoluteLayout.SetLayoutFlags(actIndicator, AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(actIndicator, new Rectangle(0.5, 0.5, -1, -1));
abs.Children.Add(actIndicator);
#endregion
this.Content = abs;
}
示例3: SimonSaysPage
//.........这里部分代码省略.........
var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);
layout.Children.Add(red,
xConstraint: Constraint.Constant(AppSettings.Margin),
yConstraint: Constraint.Constant(AppSettings.Margin),
widthConstraint: buttonConstraint,
heightConstraint: buttonConstraint
);
layout.Children.Add(yellow,
xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
yConstraint: Constraint.Constant(AppSettings.Margin),
widthConstraint: buttonConstraint,
heightConstraint: buttonConstraint
);
layout.Children.Add(blue,
xConstraint: Constraint.Constant(AppSettings.Margin),
yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
widthConstraint: buttonConstraint,
heightConstraint: buttonConstraint
);
layout.Children.Add(green,
xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
widthConstraint: buttonConstraint,
heightConstraint: buttonConstraint
);
layout.Children.Add(lightStack,
xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
);
layout.Children.Add(clearSubmission,
xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
v.Y - 10,
v.Y - 15,
v.Y - 15
)
),
widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
);
layout.Children.Add(actionButton,
xConstraint: Constraint.Constant(AppSettings.Margin),
yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
heightConstraint: Constraint.Constant(50)
);
Content = layout;
red.Clicked += async (object sender, EventArgs e) =>
{
await ViewModel.PlayerPressButtonAsync("r");
};
blue.Clicked += async (object sender, EventArgs e) =>
{
await ViewModel.PlayerPressButtonAsync("b");
};
green.Clicked += async (object sender, EventArgs e) =>
{
await ViewModel.PlayerPressButtonAsync("g");
};
yellow.Clicked += async (object sender, EventArgs e) =>
{
await ViewModel.PlayerPressButtonAsync("y");
};
clearSubmission.Clicked += (object sender, EventArgs e) =>
{
ViewModel.ClearPlayerEntry();
};
red.SetBinding(Button.OpacityProperty, "RedOpacity");
green.SetBinding(Button.OpacityProperty, "GreenOpacity");
blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");
l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
l10.SetBinding(ContentView.BackgroundColorProperty, "L10");
clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
actionButton.SetBinding(Button.TextProperty, "ActionText");
actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
}