本文整理汇总了C#中Xamarin.Forms.Label.AddRadioToggler方法的典型用法代码示例。如果您正苦于以下问题:C# Label.AddRadioToggler方法的具体用法?C# Label.AddRadioToggler怎么用?C# Label.AddRadioToggler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.Label
的用法示例。
在下文中一共展示了Label.AddRadioToggler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorScrollPage
public ColorScrollPage()
{
// Define a 2 x 2 Grid that will be modified for portrait
// or landscape in SizeChanged handler.
mainGrid = new Grid
{
ColumnDefinitions =
{
new ColumnDefinition(),
new ColumnDefinition()
},
RowDefinitions =
{
new RowDefinition(),
new RowDefinition()
}
};
// Put all Labels and Sliders in StackLayout.
// Wait until SizeChanged to set row and column.
controllersStack = new StackLayout();
mainGrid.Children.Add(controllersStack);
// Also wait until SizeChanged to set BoxView row and column.
boxView = new BoxView
{
Color = currentColor
};
mainGrid.Children.Add(boxView);
// Assemble 3-column Grid to display color options.
Grid radioGrid = new Grid
{
VerticalOptions = LayoutOptions.CenterAndExpand,
};
string[] modeLabels = { "Hex RGB", "Float RGB", "HSL" };
foreach (ColorMode colorMode in Enum.GetValues(typeof(ColorMode)))
{
// Define a Label to be used as a radio button.
Label radioLabel = new Label
{
Text = modeLabels[(int)colorMode],
StyleId = colorMode.ToString(),
XAlign = TextAlignment.Center,
Opacity = 0.5
};
radioLabel.AddRadioToggler(OnRadioLabelToggled);
// Set default item.
radioLabel.SetRadioState(colorMode == ColorMode.RgbHex);
// Add it to the Grid.
radioGrid.Children.AddHorizontal(radioLabel);
// Set the column width to "star" to equally space them.
radioGrid.ColumnDefinitions.Add(new ColumnDefinition
{
Width = new GridLength(1, GridUnitType.Star)
});
}
controllersStack.Children.Add(radioGrid);
// Create Labels and Sliders for the three color components.
for (int component = 0; component < 3; component++)
{
labels[component] = new Label
{
XAlign = TextAlignment.Center
};
controllersStack.Children.Add(labels[component]);
// Set same ValueChanged handler for all sliders.
sliders[component] = new Slider();
sliders[component].ValueChanged += OnSliderValueChanged;
controllersStack.Children.Add(sliders[component]);
}
// Build page.
this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
this.Content = mainGrid;
// Set SizeChanged handler.
SizeChanged += OnPageSizeChanged;
// Initialize Slider values.
SetSlidersAndBindings ();
}