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


C# Label.SetRadioState方法代码示例

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


在下文中一共展示了Label.SetRadioState方法的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 ();
        }
开发者ID:karanga,项目名称:xamarin-forms-book-preview,代码行数:89,代码来源:ColorScrollPage.cs


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