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


C# MenuItem.SetBinding方法代码示例

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


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

示例1: CustomTextCell

			public CustomTextCell ()
			{
				SetBinding (TextProperty, new Binding ("Title"));
				var deleteMenuItem = new MenuItem ();
				deleteMenuItem.Text = "Delete";
				deleteMenuItem.IsDestructive = true;
				deleteMenuItem.SetBinding (MenuItem.CommandProperty, new Binding ("DeleteItemCommand"));
				ContextActions.Add (deleteMenuItem);
			}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:9,代码来源:Bugzilla31330.cs

示例2: CaCell

			public CaCell ()
			{
				var label = new Label ();
				label.SetBinding (Label.TextProperty, new Binding ("."));
				var menu = new MenuItem { Text = "Delete", IsDestructive = true };
				menu.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
				var menu1 = new MenuItem { Text = "Settings"  };
				menu1.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
				ContextActions.Add (menu);
				ContextActions.Add (menu1);

				var stack = new StackLayout ();
				stack.Children.Add (label);
				View = stack;
			}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:15,代码来源:Issue3276.cs

示例3: MessageCell

			public MessageCell()
			{
				this.SetBinding (TextProperty, "Subject");
				this.SetBinding (DetailProperty, "MessagePreview");

				var delete = new MenuItem { Text = "Delete", IsDestructive = true };
				delete.SetBinding (MenuItem.CommandProperty, "Delete");

				var mark = new MenuItem { Text = "Mark",  Icon = "calculator.png" };
				var move = new MenuItem { Text = "Move" };

				//move.Clicked += async (sender, e) => await Navigation.PopAsync();

				ContextActions.Add (mark);
				ContextActions.Add (delete);
				ContextActions.Add (move);

				var clear = new MenuItem { Text = "Clear Items" };
				clear.Clicked += (sender, args) => ContextActions.Clear();
				ContextActions.Add (clear);
			}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:21,代码来源:EditableList.cs

示例4: Init

			void Init(bool fast)
			{
				_photo = new Image
				{
					HeightRequest = 52,
					WidthRequest = 52,                
				};


				_mainLabel = new Label() { HeightRequest = 40, FontSize = 24, TranslationY = 5, LineBreakMode = LineBreakMode.TailTruncation };
				_mainLabel.SetBinding(Label.TextProperty, "PrimaryLabelText");

				_secondaryLabel = new Label() { HeightRequest = 40, FontSize = 16, TranslationY = -5, LineBreakMode = LineBreakMode.TailTruncation };
				_secondaryLabel.SetBinding(Label.TextProperty, "SecondaryLabelText");

#pragma warning disable 618
				_distanceLabel = new Label() { XAlign = TextAlignment.End, HorizontalOptions = LayoutOptions.EndAndExpand, FontSize = 11, LineBreakMode = LineBreakMode.NoWrap };
#pragma warning restore 618
				_distanceLabel.SetBinding(Label.TextProperty, "OtherLabelText");

				_statusCircle = new Label()
				{                
					HorizontalOptions = LayoutOptions.EndAndExpand, 
					FontSize = 30,
					TranslationY = 0,
				};

				_primaryContent = new StackLayout()
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					Orientation = StackOrientation.Vertical,
					Children =
					{                            
						_mainLabel,
						_secondaryLabel,
					},                    
					Padding = new Thickness(12, 0, 0, 0),
				};

				_secondaryContent = new StackLayout()
				{
					MinimumWidthRequest = 50, 
					HorizontalOptions = LayoutOptions.EndAndExpand,
					Children =
					{
						_distanceLabel,
						_statusCircle,
					},
					Padding = new Thickness(0, 5, 5, 0),
				};

				_stackLayout = new StackLayout
				{
					Orientation = StackOrientation.Horizontal,
					Children =
					{
						_photo,
						_primaryContent,
						_secondaryContent,
					},
					Padding = new Thickness(5, 0, 0, 0) 
				};

				if (!fast)
				{
					View = _stackLayout;
				}
				else
				{
					_quickCompleteMenu = new MenuItem { Text = "Complete", IsDestructive = false };
					_quickCompleteMenu.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));

					// Delete context menu action
					_quickCompleteMenu.Clicked += (sender, e) =>
					{
						FastCompleteForCmd(sender);
					};

					// Add this action to the cell
					ContextActions.Add(_quickCompleteMenu);

					_masterLayout = new AbsoluteLayout();

					_masterLayout.Children.Add(_stackLayout);

					AbsoluteLayout.SetLayoutFlags(_stackLayout, AbsoluteLayoutFlags.All);
					AbsoluteLayout.SetLayoutBounds(_stackLayout, new Rectangle(0.0, 0.0, 1.0f, 1.0f));

					View = _masterLayout;
				}
			}
开发者ID:cosullivan,项目名称:Xamarin.Forms,代码行数:91,代码来源:Bugzilla31114.cs


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