本文整理匯總了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 ();
}