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


C# Button.SetBinding方法代码示例

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


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

示例1: Init

		protected override void Init()
		{
			var ts = new TableSection();
			var tr = new TableRoot { ts };
			var tv = new TableView(tr);

			var sc = new SwitchCell
			{
				Text = "Toggle switch; nothing should crash"
			};

			var button = new Button();
			button.SetBinding(Button.TextProperty, new Binding("On", source: sc));

			var vc = new ViewCell
			{
				View = button
			};
			vc.SetBinding(IsEnabledProperty, new Binding("On", source: sc));

			ts.Add(sc);
			ts.Add(vc);

			Content = tv;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:Bugzilla36955.cs

示例2: r_11_dtMethod

 private static UIElement r_11_dtMethod(UIElement parent)
 {
     // e_69 element
     Border e_69 = new Border();
     e_69.Parent = parent;
     e_69.Name = "e_69";
     e_69.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255));
     // e_70 element
     StackPanel e_70 = new StackPanel();
     e_69.Child = e_70;
     e_70.Name = "e_70";
     // e_71 element
     TextBlock e_71 = new TextBlock();
     e_70.Children.Add(e_71);
     e_71.Name = "e_71";
     e_71.HorizontalAlignment = HorizontalAlignment.Center;
     e_71.VerticalAlignment = VerticalAlignment.Center;
     Binding binding_e_71_Text = new Binding("TextData");
     e_71.SetBinding(TextBlock.TextProperty, binding_e_71_Text);
     // e_72 element
     Button e_72 = new Button();
     e_70.Children.Add(e_72);
     e_72.Name = "e_72";
     e_72.Content = "Hide Window";
     Binding binding_e_72_Command = new Binding("HideCommand");
     e_72.SetBinding(Button.CommandProperty, binding_e_72_Command);
     return e_69;
 }
开发者ID:Mike-EEE,项目名称:UI_Examples,代码行数:28,代码来源:Dictionary.xaml.cs

示例3: SampleListActionView

				public SampleListActionView ()
				{
					var overallGrid = new Grid {
						BackgroundColor = Color.FromHex ("FAFAFA"),
						HorizontalOptions = LayoutOptions.FillAndExpand,
						VerticalOptions = LayoutOptions.CenterAndExpand,
						ColumnDefinitions = {
							new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
							new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
						}
					};

					var grid = new Grid {
						VerticalOptions = LayoutOptions.FillAndExpand,
						HorizontalOptions = LayoutOptions.FillAndExpand,
						ColumnDefinitions = {
							new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
							new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
						}
					};
					// 1 Deny
					var denyBtn = new Button {
						ClassId = "btnReject",
						Text = "DENY",
						HorizontalOptions = LayoutOptions.FillAndExpand,
						VerticalOptions = LayoutOptions.FillAndExpand
					};

					denyBtn.SetBinding (Button.CommandProperty, Binding.Create<TestViewModel> (r => r.DenyCommand));

					grid.Children.Add (denyBtn);

					// 2 Approve
					var approveBtn = new Button {
						ClassId = "btnApprove",
						Text = "Approve",
						HorizontalOptions = LayoutOptions.FillAndExpand,
						VerticalOptions = LayoutOptions.FillAndExpand,

					};
					Grid.SetColumn (approveBtn, 1);
					approveBtn.SetBinding (Button.CommandProperty, Binding.Create<TestViewModel> (r => r.ApproveCommand));
					grid.Children.Add (approveBtn);


					Grid.SetColumn (grid, 1);
					overallGrid.Children.Add (grid);
					Content = overallGrid;
				}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:49,代码来源:Bugzilla34720.cs

示例4: Get_TabControl_Items

 private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
 {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_3 element
     TabItem e_3 = new TabItem();
     e_3.Name = "e_3";
     e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     e_3.Header = "Controls";
     // e_4 element
     Grid e_4 = new Grid();
     e_3.Content = e_4;
     e_4.Name = "e_4";
     RowDefinition row_e_4_0 = new RowDefinition();
     row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_0);
     RowDefinition row_e_4_1 = new RowDefinition();
     row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_1);
     RowDefinition row_e_4_2 = new RowDefinition();
     row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_2);
     RowDefinition row_e_4_3 = new RowDefinition();
     row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_3);
     RowDefinition row_e_4_4 = new RowDefinition();
     row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_4);
     RowDefinition row_e_4_5 = new RowDefinition();
     row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_5);
     RowDefinition row_e_4_6 = new RowDefinition();
     row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_6);
     RowDefinition row_e_4_7 = new RowDefinition();
     row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_7);
     RowDefinition row_e_4_8 = new RowDefinition();
     row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_8);
     RowDefinition row_e_4_9 = new RowDefinition();
     row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_9);
     ColumnDefinition col_e_4_0 = new ColumnDefinition();
     col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_4.ColumnDefinitions.Add(col_e_4_0);
     ColumnDefinition col_e_4_1 = new ColumnDefinition();
     e_4.ColumnDefinitions.Add(col_e_4_1);
     // e_5 element
     TextBlock e_5 = new TextBlock();
     e_4.Children.Add(e_5);
     e_5.Name = "e_5";
     e_5.VerticalAlignment = VerticalAlignment.Center;
     e_5.Text = "Button";
     // button1 element
     Button button1 = new Button();
     e_4.Children.Add(button1);
     button1.Name = "button1";
     button1.Height = 30F;
     button1.Width = 200F;
     button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     button1.HorizontalAlignment = HorizontalAlignment.Left;
     button1.TabIndex = 1;
     button1.Content = "Button 1";
     button1.CommandParameter = "Click Button 1";
     Grid.SetColumn(button1, 1);
     Grid.SetRow(button1, 0);
     Binding binding_button1_Command = new Binding("ButtonCommand");
     button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     Button button2 = new Button();
     e_4.Children.Add(button2);
     button2.Name = "button2";
     button2.Height = 30F;
     button2.Width = 200F;
     button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     button2.HorizontalAlignment = HorizontalAlignment.Left;
     button2.TabIndex = 2;
     button2.Content = "Button 2";
     button2.CommandParameter = "Click Button 2";
     Grid.SetColumn(button2, 1);
     Grid.SetRow(button2, 1);
     Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
     button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
     Binding binding_button2_Command = new Binding("ButtonCommand");
     button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     // buttonResult element
     TextBlock buttonResult = new TextBlock();
     e_4.Children.Add(buttonResult);
     buttonResult.Name = "buttonResult";
     buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(buttonResult, 1);
     Grid.SetRow(buttonResult, 2);
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
     // e_6 element
     TextBlock e_6 = new TextBlock();
     e_4.Children.Add(e_6);
     e_6.Name = "e_6";
     e_6.VerticalAlignment = VerticalAlignment.Center;
     e_6.Text = "CheckBox";
//.........这里部分代码省略.........
开发者ID:Mike-EEE,项目名称:UI_Examples,代码行数:101,代码来源:BasicUI.xaml.cs

示例5: SetActionsToButton

    public static void SetActionsToButton(Button button, FAFramework.Forms.Manual.WindowOperation.Operation[] actions, KeyValuePair<string, Func<bool>>[] status, string unknownName = "UNKNOWN")
    {
        FAFramework.Forms.Manual.WindowOperation.SetActionToButton(button, actions);

        var obj = new PartStatus();

        var tempStatus = status;
        var tempUnknownName = unknownName;
        obj.Execute =
            delegate()
            {
                foreach (var item in tempStatus)
                {
                    if (item.Value() == true)
                    {
                        obj.Status = item.Key;
                        return;
                    }
                }

                obj.Status = tempUnknownName;
            };

        Binding bd = new Binding("Status");
        bd.Source = obj;
        bd.Mode = BindingMode.OneWay;
        button.SetBinding(Button.ContentProperty, bd);

        GUIUpdateManager.Instance.Items.Add(obj.Execute);
    }
开发者ID:vesteksoftware,项目名称:VT5025,代码行数:30,代码来源:UIUtility.cs

示例6: SetActionsOfTwoWayMotorPartToButton

    public static void SetActionsOfTwoWayMotorPartToButton(Button button, FALibrary.Part.MemoryBasePart.FAPartTwoWayACMotor part)
    {
        FAFramework.Forms.Manual.WindowOperation.SetActionToButton(button,
            new FAFramework.Forms.Manual.WindowOperation.Operation("FORWARD RUN", part.RunAction.Execute),
            new FAFramework.Forms.Manual.WindowOperation.Operation("REVERSE RUN", part.ReverseRunAction.Execute),
            new FAFramework.Forms.Manual.WindowOperation.Operation("STOP", part.StopAction.Execute));

        Binding bd = new Binding("Status");
        bd.Source = part;
        bd.Mode = BindingMode.OneWay;
        button.SetBinding(Button.ContentProperty, bd);
    }
开发者ID:vesteksoftware,项目名称:VT5025,代码行数:12,代码来源:UIUtility.cs

示例7: SetActionsOfGeneralPartToButton

    public static void SetActionsOfGeneralPartToButton(Button button, FALibrary.Part.MemoryBasePart.FAPartMemoryBaseGeneric part, string onName, string offName, string unknownName = "UNKNOWN")
    {
        FAFramework.Forms.Manual.WindowOperation.SetActionToButton(button,
            new FAFramework.Forms.Manual.WindowOperation.Operation(onName, part.TurnOnAction.Execute),
            new FAFramework.Forms.Manual.WindowOperation.Operation(offName, part.TurnOffAction.Execute));

        var obj = new GenericPartStatus(part, onName, offName, unknownName);
        Binding bd = new Binding("Status");
        bd.Source = obj;
        bd.Mode = BindingMode.OneWay;
        button.SetBinding(Button.ContentProperty, bd);

        GUIUpdateManager.Instance.Items.Add(obj.Execute);
    }
开发者ID:vesteksoftware,项目名称:VT5025,代码行数:14,代码来源:UIUtility.cs

示例8: Get_TabControl_Items

 private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
 {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_3 element
     TabItem e_3 = new TabItem();
     e_3.Name = "e_3";
     e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     e_3.Header = "Controls";
     // e_4 element
     Grid e_4 = new Grid();
     e_3.Content = e_4;
     e_4.Name = "e_4";
     RowDefinition row_e_4_0 = new RowDefinition();
     row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_0);
     RowDefinition row_e_4_1 = new RowDefinition();
     row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_1);
     RowDefinition row_e_4_2 = new RowDefinition();
     row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_2);
     RowDefinition row_e_4_3 = new RowDefinition();
     row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_3);
     RowDefinition row_e_4_4 = new RowDefinition();
     row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_4);
     RowDefinition row_e_4_5 = new RowDefinition();
     row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_5);
     RowDefinition row_e_4_6 = new RowDefinition();
     row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_6);
     RowDefinition row_e_4_7 = new RowDefinition();
     row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_7);
     RowDefinition row_e_4_8 = new RowDefinition();
     row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_8);
     RowDefinition row_e_4_9 = new RowDefinition();
     row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_9);
     RowDefinition row_e_4_10 = new RowDefinition();
     row_e_4_10.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_10);
     RowDefinition row_e_4_11 = new RowDefinition();
     row_e_4_11.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_11);
     ColumnDefinition col_e_4_0 = new ColumnDefinition();
     col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_4.ColumnDefinitions.Add(col_e_4_0);
     ColumnDefinition col_e_4_1 = new ColumnDefinition();
     e_4.ColumnDefinitions.Add(col_e_4_1);
     // e_5 element
     TextBlock e_5 = new TextBlock();
     e_4.Children.Add(e_5);
     e_5.Name = "e_5";
     e_5.VerticalAlignment = VerticalAlignment.Center;
     e_5.Text = "Button";
     // button1 element
     Button button1 = new Button();
     e_4.Children.Add(button1);
     button1.Name = "button1";
     button1.Height = 30F;
     button1.Width = 200F;
     button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     button1.HorizontalAlignment = HorizontalAlignment.Left;
     button1.TabIndex = 1;
     button1.Content = "Button 1";
     button1.CommandParameter = "Click Button 1";
     Grid.SetColumn(button1, 1);
     Grid.SetRow(button1, 0);
     Binding binding_button1_Command = new Binding("ButtonCommand");
     button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     Button button2 = new Button();
     e_4.Children.Add(button2);
     button2.Name = "button2";
     button2.Height = 30F;
     button2.Width = 200F;
     button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     button2.HorizontalAlignment = HorizontalAlignment.Left;
     button2.TabIndex = 2;
     button2.Content = "Button 2";
     button2.CommandParameter = "Click Button 2";
     Grid.SetColumn(button2, 1);
     Grid.SetRow(button2, 1);
     Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
     button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
     Binding binding_button2_Command = new Binding("ButtonCommand");
     button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     // buttonResult element
     TextBlock buttonResult = new TextBlock();
     e_4.Children.Add(buttonResult);
     buttonResult.Name = "buttonResult";
     buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(buttonResult, 1);
     Grid.SetRow(buttonResult, 2);
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
//.........这里部分代码省略.........
开发者ID:EmptyKeys,项目名称:UI_Examples,代码行数:101,代码来源:BasicUI.xaml.cs

示例9: Get_TabControl_Items

 private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items() {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_1 element
     TabItem e_1 = new TabItem();
     e_1.Name = "e_1";
     e_1.Header = "Players";
     // e_2 element
     Grid e_2 = new Grid();
     e_1.Content = e_2;
     e_2.Name = "e_2";
     // PlayersDataGrid element
     DataGrid PlayersDataGrid = new DataGrid();
     e_2.Children.Add(PlayersDataGrid);
     PlayersDataGrid.Name = "PlayersDataGrid";
     PlayersDataGrid.AutoGenerateColumns = false;
     DataGridTextColumn PlayersDataGrid_Col0 = new DataGridTextColumn();
     PlayersDataGrid_Col0.Header = "#";
     Binding PlayersDataGrid_Col0_b = new Binding("Number");
     PlayersDataGrid_Col0.Binding = PlayersDataGrid_Col0_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col0);
     DataGridTextColumn PlayersDataGrid_Col1 = new DataGridTextColumn();
     PlayersDataGrid_Col1.Header = "Name";
     Binding PlayersDataGrid_Col1_b = new Binding("Name");
     PlayersDataGrid_Col1.Binding = PlayersDataGrid_Col1_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col1);
     DataGridTextColumn PlayersDataGrid_Col2 = new DataGridTextColumn();
     PlayersDataGrid_Col2.Header = "GameJolt ID";
     Binding PlayersDataGrid_Col2_b = new Binding("GameJoltID");
     PlayersDataGrid_Col2.Binding = PlayersDataGrid_Col2_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col2);
     DataGridTextColumn PlayersDataGrid_Col3 = new DataGridTextColumn();
     PlayersDataGrid_Col3.Header = "Location";
     Binding PlayersDataGrid_Col3_b = new Binding("LevelFile");
     PlayersDataGrid_Col3.Binding = PlayersDataGrid_Col3_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col3);
     DataGridTextColumn PlayersDataGrid_Col4 = new DataGridTextColumn();
     PlayersDataGrid_Col4.Header = "Play Time";
     Binding PlayersDataGrid_Col4_b = new Binding("PlayTime");
     PlayersDataGrid_Col4.Binding = PlayersDataGrid_Col4_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col4);
     DataGridTextColumn PlayersDataGrid_Col5 = new DataGridTextColumn();
     PlayersDataGrid_Col5.Header = "IP";
     Binding PlayersDataGrid_Col5_b = new Binding("IP");
     PlayersDataGrid_Col5.Binding = PlayersDataGrid_Col5_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col5);
     DataGridTextColumn PlayersDataGrid_Col6 = new DataGridTextColumn();
     PlayersDataGrid_Col6.Header = "Ping";
     Binding PlayersDataGrid_Col6_b = new Binding("Ping");
     PlayersDataGrid_Col6.Binding = PlayersDataGrid_Col6_b;
     PlayersDataGrid.Columns.Add(PlayersDataGrid_Col6);
     Grid.SetColumnSpan(PlayersDataGrid, 2);
     Binding binding_PlayersDataGrid_ItemsSource = new Binding("PlayersGridDataList");
     PlayersDataGrid.SetBinding(DataGrid.ItemsSourceProperty, binding_PlayersDataGrid_ItemsSource);
     items.Add(e_1);
     // e_3 element
     TabItem e_3 = new TabItem();
     e_3.Name = "e_3";
     e_3.Header = "Bans";
     // e_4 element
     Grid e_4 = new Grid();
     e_3.Content = e_4;
     e_4.Name = "e_4";
     // BansDataGrid element
     DataGrid BansDataGrid = new DataGrid();
     e_4.Children.Add(BansDataGrid);
     BansDataGrid.Name = "BansDataGrid";
     BansDataGrid.AutoGenerateColumns = false;
     DataGridTextColumn BansDataGrid_Col0 = new DataGridTextColumn();
     BansDataGrid_Col0.Header = "#";
     Binding BansDataGrid_Col0_b = new Binding("Number");
     BansDataGrid_Col0.Binding = BansDataGrid_Col0_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col0);
     DataGridTextColumn BansDataGrid_Col1 = new DataGridTextColumn();
     BansDataGrid_Col1.Header = "Name";
     Binding BansDataGrid_Col1_b = new Binding("Name");
     BansDataGrid_Col1.Binding = BansDataGrid_Col1_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col1);
     DataGridTextColumn BansDataGrid_Col2 = new DataGridTextColumn();
     BansDataGrid_Col2.Header = "GameJolt ID";
     Binding BansDataGrid_Col2_b = new Binding("GameJoltID");
     BansDataGrid_Col2.Binding = BansDataGrid_Col2_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col2);
     DataGridTextColumn BansDataGrid_Col3 = new DataGridTextColumn();
     BansDataGrid_Col3.Header = "IP";
     Binding BansDataGrid_Col3_b = new Binding("IP");
     BansDataGrid_Col3.Binding = BansDataGrid_Col3_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col3);
     DataGridTextColumn BansDataGrid_Col4 = new DataGridTextColumn();
     BansDataGrid_Col4.Header = "Minutes Left";
     Binding BansDataGrid_Col4_b = new Binding("MinutesLeft");
     BansDataGrid_Col4.Binding = BansDataGrid_Col4_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col4);
     DataGridTextColumn BansDataGrid_Col5 = new DataGridTextColumn();
     BansDataGrid_Col5.Header = "Reason";
     Binding BansDataGrid_Col5_b = new Binding("Reason");
     BansDataGrid_Col5.Binding = BansDataGrid_Col5_b;
     BansDataGrid.Columns.Add(BansDataGrid_Col5);
     Binding binding_BansDataGrid_ItemsSource = new Binding("BansGridDataList");
     BansDataGrid.SetBinding(DataGrid.ItemsSourceProperty, binding_BansDataGrid_ItemsSource);
     items.Add(e_3);
//.........这里部分代码省略.........
开发者ID:PokeD,项目名称:PokeD.SCON,代码行数:101,代码来源:BasicUI.xaml.cs

示例10: RepeaterViewPage

        public RepeaterViewPage()
        {
            var viewModel = new RepeaterViewViewModel();
            BindingContext = viewModel;

            var repeater = new RepeaterView<Thing>
            {
                Spacing = 10,
                ItemsSource = viewModel.Things,
                ItemTemplate = new DataTemplate(() =>
                {
                    var nameLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Medium) };
                    nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

                    var descriptionLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Small) };
                    descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

                    ViewCell cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Spacing = 0,
                            Children =
                            {
                                nameLabel,
                                descriptionLabel
                            }
                        }
                    };

                    return cell;
                })
            };

            var removeButton = new Button
            {
                Text = "Remove 1st Item",      
                HorizontalOptions = LayoutOptions.Start
            };

            removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

            var addButton = new Button
            {
                Text = "Add New Item",
                HorizontalOptions = LayoutOptions.Start
            };

            addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

            Content = new StackLayout
            {
                Padding = 20,
                Spacing = 5,
                Children = 
                {
                    new Label 
                    { 
                        Text = "RepeaterView Demo", 
                        Font = Font.SystemFontOfSize(NamedSize.Large)
                    },
                    repeater,
                    removeButton,
                    addButton
                }
            };

            viewModel.LoadData();
        }
开发者ID:GGHG72,项目名称:Xamarin-Forms-Labs,代码行数:69,代码来源:RepeaterViewPage.cs

示例11: TemplatedCarouselGallery

		public TemplatedCarouselGallery()
		{
			NavigationPage.SetHasNavigationBar (this, false);

			_items = new ObservableCollection<Item> {
				CreateItem(),
				CreateItem(),
			};

			ItemsSource = _items;

			ItemTemplate = new DataTemplate (() => {
				var page = new ContentPage ();

				page.Padding = new Thickness (0,30,0,0);
				page.SetBinding (TitleProperty, "Title");

				var layout = new StackLayout { Spacing = 0 };

				var label = new Label();
				label.SetBinding (Label.TextProperty, "Content");
				layout.Children.Add (label);

				var swipeHereLabel = new Label {
					Text = "Swipe Here",
					HeightRequest = 40
				};

				layout.Children.Add (swipeHereLabel);

				var add = new Button ();
				add.SetBinding (Button.TextProperty, "InsertTabText");
				add.Clicked += (sender, args) => _items.Insert (_items.IndexOf ((Item)add.BindingContext) + 1, CreateItem());
				layout.Children.Add (add);

				var change = new Button ();
				change.SetBinding (Button.TextProperty, "ChangeTitleText");
				change.Clicked += (sender, args) => ((Item) change.BindingContext).Title = (new Random().Next().ToString());
				layout.Children.Add (change);

				var remove = new Button ();
				remove.SetBinding (Button.TextProperty, "RemoveTabText");
				remove.Clicked += (sender, args) => _items.Remove ((Item)remove.BindingContext);
				layout.Children.Add (remove);

				var reset = new Button ();
				reset.SetBinding (Button.TextProperty, "ResetAllTabsText");
				reset.Clicked += (sender, args) => {
					_count = 0;
					ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
				};
				layout.Children.Add (reset);

				var nextPage = new Button ();
				nextPage.SetBinding (Button.TextProperty, "NextPageText");
				nextPage.Clicked += (sender, args) => {
					int index = _items.IndexOf ((Item) nextPage.BindingContext) + 1;
					if (index == _items.Count)
						index = 0;

					SelectedItem = _items[index];
				};
				layout.Children.Add (nextPage);

				var delayReset = new Button { Text = "Delayed reset" };
				delayReset.SetBinding (Button.TextProperty, "DelayedResetText");
				delayReset.Clicked += (sender, args) => {
					ItemsSource = null;

					Task.Delay (5000).ContinueWith (t => {
						_count = 0;
						ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
					}, TaskScheduler.FromCurrentSynchronizationContext());
				};

				layout.Children.Add (delayReset);

				page.Content = new ScrollView { 
					Padding = new Thickness (60, 0),
					Content = layout 
				};
				return page;
			});
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:84,代码来源:TemplatedCarouselGallery.cs

示例12: ComplexViewCell

		public ComplexViewCell()
		{
			if (s_mImgProdCount == null)
				s_mImgProdCount = ImageSource.FromFile ("bank.png");
			if (s_mImgEndTime == null)
				s_mImgEndTime = ImageSource.FromFile ("bank.png");
			if (s_mImgRenewal == null)
				s_mImgRenewal = ImageSource.FromFile ("bank.png");

#pragma warning disable 618
			var label1 = new Label { Text = "Label 1", Font = Font.SystemFontOfSize (NamedSize.Small, FontAttributes.Bold) };
#pragma warning restore 618
			label1.SetBinding (Label.TextProperty, new Binding ("."));

#pragma warning disable 618
			var label2 = new Label { Text = "Label 2", Font = Font.SystemFontOfSize (NamedSize.Small) };
#pragma warning restore 618

			// was ListButton?
			var button = new Button {
				Text = "X",
				BackgroundColor = Color.Gray,
				HorizontalOptions = LayoutOptions.EndAndExpand
			};
			button.SetBinding (Button.CommandParameterProperty, new Binding ("."));
			button.Clicked += (sender, e) => {
				var b = (Button) sender;
				var t = b.CommandParameter;
#pragma warning disable 618
				((ContentPage) ((ListView) ((StackLayout) b.ParentView).ParentView).ParentView).DisplayAlert ("Clicked",
#pragma warning restore 618
					t + " button was clicked", "OK");
				Debug.WriteLine ("clicked" + t);
			};

			Image imgProdCount = new Image {
				Aspect = Aspect.AspectFit,
				Source = s_mImgProdCount,
			};

			Image imgEndTime = new Image {
				Aspect = Aspect.AspectFit,
				Source = s_mImgEndTime,
			};

			Image imgRenewal = new Image {
				Aspect = Aspect.AspectFit,
				Source = s_mImgRenewal,
			};

			View = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.StartAndExpand,
				Padding = new Thickness (15, 5, 5, 15),
				Children = {
					new StackLayout {
						Orientation = StackOrientation.Vertical,
						Children = { label1, label2 }
					},
					button,
					imgProdCount,
					imgEndTime,
					imgRenewal
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:66,代码来源:ComplexListView.cs

示例13: TemplatedTabbedGallery

		public TemplatedTabbedGallery()
		{
			Title = "Templated Tabbed Gallery";
			_items = new ObservableCollection<Item> {
				CreateItem(),
				CreateItem()
			};

			ItemsSource = _items;

			ItemTemplate = new DataTemplate (() => {
				var page = new ContentPage();
				page.SetBinding (TitleProperty, "Title");
				page.SetBinding (IconProperty, "Icon");

				var layout = new StackLayout();

				var label = new Label();
				label.SetBinding (Label.TextProperty, "Content");
				layout.Children.Add (label);

				var add = new Button ();
				add.SetBinding (Button.TextProperty, "InsertTabText");
				add.Clicked += (sender, args) => _items.Insert (_items.IndexOf ((Item)add.BindingContext) + 1, CreateItem());
				layout.Children.Add (add);

				var titleNum = 0;
				var change = new Button ();
				change.SetBinding (Button.TextProperty, "ChangeTitleText");
				change.Clicked += (sender, args) => ((Item) change.BindingContext).Title = ("Title: " + titleNum++);
				layout.Children.Add (change);

				var move = new Button ();
				move.SetBinding (Button.TextProperty, "MoveTabText");
				move.Clicked += (sender, args) => {
					int originalIndex = _items.IndexOf ((Item) add.BindingContext);
					int index = originalIndex + 1;
					if (index == _items.Count)
						index = 0;

					_items.Move (originalIndex, index);
				};
				layout.Children.Add (move);

				var remove = new Button ();
				remove.SetBinding (Button.TextProperty, "RemoveTabText");
				remove.Clicked += (sender, args) => {
					if (_items.Count == 0) {
						layout.Children.Add (new Label {
							Text = "No more tabs"
						});
					}
					_items.Remove ((Item)remove.BindingContext);
				};
				layout.Children.Add (remove);

				var reset = new Button ();
				reset.SetBinding (Button.TextProperty, "ResetAllTabsText");
				reset.Clicked += (sender, args) => {
					_count = 0;
					ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
				};
				layout.Children.Add (reset);

				var nextPage = new Button ();
				nextPage.SetBinding (Button.TextProperty, "NextPageText");
				nextPage.Clicked += (sender, args) => {
					int index = _items.IndexOf ((Item) nextPage.BindingContext) + 1;
					if (index == _items.Count)
						index = 0;

					SelectedItem = _items[index];
				};
				layout.Children.Add (nextPage);

				page.Content = new ScrollView { 
					Padding = new Thickness (20, 0),
					Content = layout 
				};

				return page;
			});
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:83,代码来源:TemplatedTabbedGallery.cs

示例14: AddButtonNode

        /// <summary>
        /// ボタンのノードを追加する
        /// </summary>
        /// <param name="text"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="style"></param>
        /// <returns></returns>
        Particle AddButtonNode(string text, double x, double y, string style)
        {
            // creates a new Particle instance
            var p = sim.AddParticle(10, x, y);

            // creates a new TextBlock instance
            Button button = new Button()
            {
                Content = text,
                Style = Resources[style] as Style,
            };

            // sets binding
            button.DataContext = p;
            button.SetBinding(Canvas.LeftProperty, new Binding("x") { Mode = BindingMode.TwoWay });
            button.SetBinding(Canvas.TopProperty, new Binding("y") { Mode = BindingMode.TwoWay });

            // sets mouse event
            button.MouseLeftButtonDown += (s, e) =>
            {
                p.IsActive = false;
            };
            button.MouseLeftButtonUp += (s, e) =>
            {
                p.IsActive = true;
            };
            SetHandle(button);

            // adds
            LayoutRoot.Children.Add(button);
            particles[text] = p;

            p.IsActive = true;
            button.SizeChanged += (s, e) =>
            {
                var size = button.RenderSize;
                button.RenderTransform =
                    new TranslateTransform() { X = -size.Width / 2, Y = -size.Height / 2 };
            };

            // returns added the Particle instance
            return p;
        }
开发者ID:satomacoto,项目名称:Silverlight-Graph,代码行数:51,代码来源:Graph.xaml.cs

示例15: r_3_dtMethod

 private static UIElement r_3_dtMethod(UIElement parent)
 {
     // e_2 element
     Border e_2 = new Border();
     e_2.Parent = parent;
     e_2.Name = "e_2";
     e_2.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255));
     // e_3 element
     StackPanel e_3 = new StackPanel();
     e_2.Child = e_3;
     e_3.Name = "e_3";
     // e_4 element
     TextBlock e_4 = new TextBlock();
     e_3.Children.Add(e_4);
     e_4.Name = "e_4";
     e_4.HorizontalAlignment = HorizontalAlignment.Center;
     e_4.VerticalAlignment = VerticalAlignment.Center;
     Binding binding_e_4_Text = new Binding("TextData");
     binding_e_4_Text.UseGeneratedBindings = true;
     e_4.SetBinding(TextBlock.TextProperty, binding_e_4_Text);
     // e_5 element
     TextBlock e_5 = new TextBlock();
     e_3.Children.Add(e_5);
     e_5.Name = "e_5";
     e_5.HorizontalAlignment = HorizontalAlignment.Center;
     e_5.VerticalAlignment = VerticalAlignment.Center;
     Binding binding_e_5_Text = new Binding("ManualBinding");
     binding_e_5_Text.UseGeneratedBindings = true;
     e_5.SetBinding(TextBlock.TextProperty, binding_e_5_Text);
     // e_6 element
     Button e_6 = new Button();
     e_3.Children.Add(e_6);
     e_6.Name = "e_6";
     e_6.Content = "Hide Window";
     Binding binding_e_6_Command = new Binding("HideCommand");
     binding_e_6_Command.UseGeneratedBindings = true;
     e_6.SetBinding(Button.CommandProperty, binding_e_6_Command);
     return e_2;
 }
开发者ID:EmptyKeys,项目名称:UI_Examples,代码行数:39,代码来源:Dictionary.xaml.cs


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