本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
}