本文整理汇总了C#中Xamarin.Forms.Button类的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Button类属于Xamarin.Forms命名空间,在下文中一共展示了Button类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreatePage
ContentPage CreatePage (Color backgroundColor)
{
_index++;
var button = new Button () {
Text = "next Page",
};
button.Clicked += (sender, e) => {
var page = CreatePage (Color.Green);
_navigationPage.PushAsync (page);
};
var contentPage = new ContentPage () {
Content = new StackLayout () {
BackgroundColor = backgroundColor,
VerticalOptions = LayoutOptions.Fill,
Children = {
new Label () {
Text = "page " + _index,
},
}
}
};
return contentPage;
}
开发者ID:DevinvN,项目名称:TwinTechsFormsLib,代码行数:25,代码来源:NavigationPageInPage.xaml.cs
示例2: MyControls
public MyControls ()
{
Title = "My First Xamarin.Forms";
var label = new Label {
Text = "Custom label",
Font = Font.SystemFontOfSize (20),
TextColor = Color.Aqua,
BackgroundColor = Color.Gray,
IsVisible = true,
LineBreakMode = LineBreakMode.WordWrap
};
var button = new Button { Text = "Click Me!" };
int i = 1;
button.Clicked += (s, e) => button.Text = "You clicked me: " + i++;
button.Clicked += (s, e) => Navigation.PushAsync(new MySecondPage());
Content = new StackLayout {
Spacing = 10,
VerticalOptions = LayoutOptions.Center,
Children = {
label,
button
}
};
}
开发者ID:JeffHarms,项目名称:xamarin-forms-samples-1,代码行数:28,代码来源:MyControls.cs
示例3: ScriptInputGroupPage
public ScriptInputGroupPage(InputGroup inputGroup, List<InputGroup> previousInputGroups)
{
Title = "Input Group";
StackLayout contentLayout = new StackLayout
{
Orientation = StackOrientation.Vertical,
VerticalOptions = LayoutOptions.FillAndExpand
};
foreach (StackLayout stack in UiProperty.GetPropertyStacks(inputGroup))
contentLayout.Children.Add(stack);
Button editInputsButton = new Button
{
Text = "Edit Inputs",
FontSize = 20,
HorizontalOptions = LayoutOptions.FillAndExpand
};
editInputsButton.Clicked += async (o, e) =>
{
await Navigation.PushAsync(new ScriptInputsPage(inputGroup, previousInputGroups));
};
contentLayout.Children.Add(editInputsButton);
Content = new ScrollView
{
Content = contentLayout
};
}
开发者ID:shamik94,项目名称:sensus,代码行数:32,代码来源:ScriptInputGroupPage.cs
示例4: ProductImagePage
public ProductImagePage(ImageSource productImageSource)
{
Padding = Device.OnPlatform(new Thickness(0, 20, 0, 0), new Thickness(0), new Thickness(0));
_productImageSource = productImageSource;
BackgroundColor = Color.FromRgba(0, 0, 0, 127);
var absoluteLayout = new AbsoluteLayout
{
VerticalOptions = LayoutOptions.FillAndExpand
};
var closeButtom = new Button
{
WidthRequest = 50,
Image = "backspace.png",
BackgroundColor = Color.Transparent
};
closeButtom.Clicked += OnCloseButtonClicked;
var image = new Image
{
Source = _productImageSource
};
AbsoluteLayout.SetLayoutFlags(closeButtom, AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(closeButtom, new Rectangle(1f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(image, new Rectangle(0.5f, 0.5f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
absoluteLayout.Children.Add(image);
absoluteLayout.Children.Add(closeButtom);
Content = absoluteLayout;
}
开发者ID:maxklippa,项目名称:eCommerce,代码行数:30,代码来源:ProductImagePage.cs
示例5: HomePageCS
public HomePageCS ()
{
var rotateButton = new Button { Text = "Rotate Animation" };
rotateButton.Clicked += OnRotateAnimationButtonClicked;
var relativeRotateButton = new Button { Text = "Relative Rotate Animation" };
relativeRotateButton.Clicked += OnRelativeRotateAnimationButtonClicked;
var rotateAnchorButton = new Button { Text = "Rotate Animation with Anchors" };
rotateAnchorButton.Clicked += OnRotateAnimationWithAnchorsButtonClicked;
var multipleRotateButton = new Button { Text = "Multiple Rotations" };
multipleRotateButton.Clicked += OnMultipleRotationAnimationButtonClicked;
var scaleButton = new Button { Text = "Scale Animation" };
scaleButton.Clicked += OnScaleAnimationButtonClicked;
var relativeScaleButton = new Button { Text = "Relative Scale Animation" };
relativeScaleButton.Clicked += OnRelativeScaleAnimationButtonClicked;
var transformButton = new Button { Text = "Transform Animation" };
transformButton.Clicked += OnTransformAnimationButtonClicked;
var fadeButton = new Button { Text = "Fade Animation" };
fadeButton.Clicked += OnFadeAnimationButtonClicked;
Title = "Basic Animation Demo";
Content = new StackLayout {
Margin = new Thickness (0, 20, 0, 0),
Children = {
rotateButton,
relativeRotateButton,
rotateAnchorButton,
multipleRotateButton,
scaleButton,
relativeScaleButton,
transformButton,
fadeButton
}
};
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:34,代码来源:HomePageCS.cs
示例6: Pagina1
public Pagina1()
{
Label texto = new Label {
Text = "Página 1",
TextColor = Color.Blue
};
Button boton = new Button
{
Text = "Click para navegar a la página DOS"
};
boton.Clicked += (sender, e) => {
this.Navigation.PushAsync(new Pagina2());
};
//Stacklayout permite apilar los controles verticalmente
StackLayout stackLayout = new StackLayout
{
Children =
{
texto,
boton
}
};
//Como esta clase hereda de ContentPage, podemos usar estas propiedades directamente
this.Content = stackLayout;
this.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5);
}
开发者ID:dtorress,项目名称:XamActivities,代码行数:30,代码来源:Pagina1.cs
示例7: RequiredFieldTriggerPage
public RequiredFieldTriggerPage ()
{
var l = new Label {
Text = "Entry requires length>0 before button is enabled",
};
l.FontSize = Device.GetNamedSize (NamedSize.Small, l);
var e = new Entry { Placeholder = "enter name" };
var b = new Button { Text = "Save",
HorizontalOptions = LayoutOptions.Center
};
b.FontSize = Device.GetNamedSize (NamedSize.Large ,b);
var dt = new DataTrigger (typeof(Button));
dt.Binding = new Binding ("Text.Length", BindingMode.Default, source: e);
dt.Value = 0;
dt.Setters.Add (new Setter { Property = Button.IsEnabledProperty, Value = false });
b.Triggers.Add (dt);
Content = new StackLayout {
Padding = new Thickness(0,20,0,0),
Children = {
l,
e,
b
}
};
}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:30,代码来源:RequiredFieldTriggerPage.cs
示例8: InitialPage
public InitialPage()
{
BindingContext = new InitialPageModel (this.Navigation);
Title = "Welcome to Peter";
Label timeLabel = new Label {
HorizontalOptions = LayoutOptions.Center,
};
timeLabel.SetBinding<InitialPageModel> (Label.TextProperty, vm => vm.DrinkingHoursDisplay);
Slider timeSlider = new Slider (1, 24, 5) {
HorizontalOptions = LayoutOptions.FillAndExpand,
};
timeSlider.SetBinding<InitialPageModel> (Slider.ValueProperty, vm => vm.DrinkingHours, BindingMode.TwoWay);
Button pressMe = new Button {
Text = "Help Peter",
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
FontSize = 60,
HeightRequest = 200,
BackgroundColor = Color.Yellow,
};
pressMe.SetBinding<InitialPageModel> (Button.CommandProperty, vm => vm.PressMeCommand);
Content = new StackLayout {
Children = {
timeLabel,
timeSlider,
pressMe,
}
};
}
开发者ID:RickNabb,项目名称:Peter,代码行数:34,代码来源:InitialPage.cs
示例9: App
public App()
{
var btnCs = new Button()
{
Text = "Abas Code Only"
};
btnCs.Clicked += btnCs_Clicked;
var btnXaml = new Button()
{
Text = "Abas XAML"
};
btnXaml.Clicked += btnXaml_Clicked;
// The root page of your application
MainPage = new NavigationPage(new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Abra uma das Telas"
},
btnCs,
btnXaml
}
}
});
}
开发者ID:rafaelrmou,项目名称:HowUseTabbedPage,代码行数:31,代码来源:App.cs
示例10: Page2
public Page2()
{
var label = new Label { Text = "Hello ContentPage 2" };
Device.OnPlatform(
iOS: () => {
var parentTabbedPage = this.ParentTabbedPage() as MainTabbedPage;
if (parentTabbedPage != null) {
// HACK: get content out from under status bar if a navigation bar isn't doing that for us already.
Padding = new Thickness(Padding.Left, Padding.Top + 25f, Padding.Right, Padding.Bottom);
}
}
);
var button = new Button() {
Text = "Switch to Tab 1; add a Page 2 there",
};
button.Clicked += async (sender, e) => {
var tabbedPage = this.ParentTabbedPage() as MainTabbedPage;
var partPage = new Page2() { Title = "Added page 2" };
await tabbedPage.SwitchToTab1(partPage, resetToRootFirst: false);
};
Content = new StackLayout {
Children = {
button,
label,
}
};
}
开发者ID:jv9,项目名称:XamarinForms-Tabs-Demo,代码行数:27,代码来源:Page2.cs
示例11: MultipleChoiceQuestion
public MultipleChoiceQuestion ()
{
Title = "Multiple Choice";
Label q1 = new Label{ Text = "Identify the visual field defect below." };
var answers = new String[]{"Choose an option", "Bitemporal hemianopia", "Binasal hemianopia", "Central scotoma", "Right homonymous hemianopia", "Temporal homonymous hemianopia"};
Picker q1a = new Picker ();
foreach (var a in answers) {
q1a.Items.Add (a);
}
var button = new Button {Text="Submit"};
button.Clicked += (object sender, EventArgs e) => {
if(q1a.SelectedIndex == 1){
DisplayAlert("Correct!", "Well done, that's the right answer", "OK");
}else{
DisplayAlert("Incorrect", String.Format("The correct answer is {0}", answers[1]), "OK");
}
};
Content = new StackLayout {
Children = {
q1,
new Image{
Source = ImageSource.FromUri(new Uri("http://i.imgur.com/q7l03ZG.png"))
},
q1a,
button
}
};
}
开发者ID:JosephRedfern,项目名称:EyeZapApp,代码行数:34,代码来源:MultipleChoiceQuestion.cs
示例12: ContentDemo
public ContentDemo()
{
Button button = new Button
{
Text = "Edit Profile",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
button.Clicked += OnButtonClicked;
Image myImage = new Image
{
Aspect = Aspect.Fill,
Source = ImageSource.FromUri( new Uri(@"https://4e72eb44013d543eb0c67f8fbddf2ed30743ec8d.googledrive.com/host/0B70CO9lnNPfceHNFLXh2Wm8yMHc/List-Most-Expensive-Cars-photo-OdYL.jpg"))
};
this.Title = "Content Page";
RelativeLayout relativeLayout = new RelativeLayout ();
relativeLayout.Children.Add (myImage,
Constraint.Constant (0),
Constraint.Constant (0),
Constraint.RelativeToParent ((parent) => { return parent.Width; }),
Constraint.RelativeToParent ((parent) => { return parent.Height; }));
relativeLayout.Children.Add (button,
Constraint.RelativeToParent ((parent) => {return parent.Width/2;} ),
Constraint.RelativeToParent ((parent) => {return parent.Height/2;} ),
Constraint.RelativeToParent ((parent) => { return 75.0; }),
Constraint.RelativeToParent ((parent) => { return 75.0; }));
Content = relativeLayout;
}
开发者ID:ctsxamarintraining,项目名称:cts440202,代码行数:33,代码来源:ContentDemo.cs
示例13: MyPage
public MyPage()
{
Button buttonToUpdate = new Button {Text = "Image Button", Image = "icon.png"};
Button UpdatesList = new Button {Text="Add Item to list"};
buttonToUpdate.SetBinding (Button.ImageProperty, new Binding("ImagePath"));
UpdatesList.Clicked += (sender,e) => {
listToWatch.Add (DateTime.Now.ToString());
};
listToWatch.CollectionChanged+=(sender,e)=>{
if( listToWatch.Count%2==1)
{
ImagePath="noci.png";
}
else
{
ImagePath="icon.png";
}
};
Content = new StackLayout {
Children = {
buttonToUpdate,
UpdatesList
}
};
Content.BindingContext = this;
}
开发者ID:DavidStrickland0,项目名称:Xamarin-Forms-Samples,代码行数:26,代码来源:MyPage.cs
示例14: TableView
public TableView(MatrixMainPageView mainView)
{
InitializeComponent();
_mainView = mainView;
Title = "Таблица";
if (Device.OS == TargetPlatform.iOS)
{
Icon = "tableTabIcon.png";
{
var btn = new Button() { Text = "Фильтры" };
btn.Clicked += (s, e) =>
{
mainView.IsPresented = !mainView.IsPresented;
};
Grid.SetRow(btn,1);
cnvRoot.Children.Add(btn);
}
}
cnvRoot.Padding = Device.OnPlatform(10, 8, 10);
ThemeManager.ThemeName = Themes.Light;
dataGrid.RightSwipeButtons.Add(new SwipeButtonInfo()
{
BackgroundColor = Color.Yellow,
TextColor = Color.Black,
AutoCloseOnTap = true,
Caption = "График"
});
dataGrid.SwipeButtonClick += DataGrid_SwipeButtonClick;
}
开发者ID:LordOfSmiles,项目名称:MatrixBuilderTest,代码行数:35,代码来源:TableView.xaml.cs
示例15: FilterPage
public FilterPage ()
{
this.Icon = "slideout.png";
this.Title = "Filter";
_scope = App.AutoFacContainer.BeginLifetimeScope();
var vm = _scope.Resolve<FilterViewModel> ();
BindingContext = vm;
var layout = new StackLayout ();
layout.Children.Add (new Label() {Text = "Enter a filter"});
layout.Children.Add (new Label() {Text = "Subject"});
var subjectEntry = new Entry();
subjectEntry.SetBinding (Entry.TextProperty, "Subject");
layout.Children.Add (subjectEntry);
var button = new Button () { Text = "Apply Filter" };
button.SetBinding (Button.CommandProperty, "FilterMeasures");
layout.Children.Add (button);
Content = layout;
}
开发者ID:jscote,项目名称:Meezure,代码行数:26,代码来源:FilterPage.xaml.cs
示例16: GlobalPage1
public GlobalPage1()
{
Title = "First Global Page";
Label homeLabel = new Label
{
Text = "Assigning id = 12345",
FontSize = 40
};
firstButton = new Button
{
Text = "Go to Second Page"
};
firstButton.Clicked += async (sendernav, args) =>
await Navigation.PushAsync(new GlobalPage2());
var stackLayout = new StackLayout
{
Children = { homeLabel, firstButton }
};
this.Content = stackLayout;
Global.Instance.myData = "12345";
}
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:28,代码来源:GlobalPage1.cs
示例17: 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
示例18: LoginPage
public LoginPage(ILoginManager ilm)
{
var button = new Button { Text = "Login" };
button.Clicked += (sender, e) => {
if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text))
{
DisplayAlert("Validation Error", "Username and Password are required", "Re-try");
} else {
// REMEMBER LOGIN STATUS!
App.Current.Properties["IsLoggedIn"] = true;
ilm.ShowMainPage();
}
};
username = new Entry { Text = "" };
password = new Entry { Text = "" };
Content = new StackLayout {
Padding = new Thickness (10, 40, 10, 10),
Children = {
new Label { Text = "Login", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) },
new Label { Text = "Username" },
username,
new Label { Text = "Password" },
password,
button
}
};
}
开发者ID:henrytranvan,项目名称:HSFFinance,代码行数:29,代码来源:LoginPage.cs
示例19: SimplestKeypad
public SimplestKeypad()
{
// Create a Vertical stack for the entire keypad.
var mainStack = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center
};
// First row is the Label.
displayLabel = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
VerticalOptions = LayoutOptions.Center,
XAlign = TextAlignment.End
};
mainStack.Children.Add(displayLabel);
//Second row is the backspace Button.
backspaceButton = new Button
{
Text = "\u21E6",
FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
IsEnabled = false
};
backspaceButton.Clicked += OnBackSpaceButtonClicked;
mainStack.Children.Add(backspaceButton);
// Now do the 10 number keys.
StackLayout rowStack = null;
for (var num = 1; num <= 10; num++)
{
if ((num - 1)%3 == 0)
{
rowStack = new StackLayout
{
Orientation = StackOrientation.Horizontal
};
mainStack.Children.Add(rowStack);
}
var digitButton = new Button
{
Text = (num % 10).ToString(),
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)),
StyleId = (num % 10).ToString()
};
digitButton.Clicked += OnDigitButtonClicked;
//For the zero button, expand to fill horizontally.
if (num == 10)
{
digitButton.HorizontalOptions = LayoutOptions.FillAndExpand;
}
rowStack.Children.Add(digitButton);
}
this.Content = mainStack;
}
开发者ID:tambama,项目名称:XamarinPreviewBook,代码行数:60,代码来源:SimplestKeypad.cs
示例20: StartStopLayout
public StartStopLayout ()
{
btnStart = new Button {
Text = "Start",
Font = Font.SystemFontOfSize (NamedSize.Large),
TextColor = Color.Black,
BackgroundColor = Color.Green,
BorderRadius = 10,
HorizontalOptions = LayoutOptions.FillAndExpand
};
btnStop = new Button {
Text = "Break",
Font = Font.SystemFontOfSize (NamedSize.Large),
TextColor = Color.Black,
BorderRadius = 10,
HorizontalOptions = LayoutOptions.FillAndExpand
};
var activeEntry = TimeManager.GetActiveTimeEntry();
if (activeEntry != null) {
btnStop.IsEnabled = true;
btnStop.BackgroundColor = Color.Red;
} else {
btnStop.IsEnabled = false;
btnStop.BackgroundColor = Color.Gray;
}
this.HorizontalOptions = LayoutOptions.FillAndExpand;
this.Orientation = StackOrientation.Horizontal;
this.Children.Add (btnStart);
this.Children.Add (btnStop);
}
开发者ID:pablomferrari,项目名称:ETCTimeApp,代码行数:32,代码来源:StartStopLayout.cs
注:本文中的Xamarin.Forms.Button类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论