• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.RadioButton类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Controls.RadioButton的典型用法代码示例。如果您正苦于以下问题:C# RadioButton类的具体用法?C# RadioButton怎么用?C# RadioButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RadioButton类属于System.Windows.Controls命名空间,在下文中一共展示了RadioButton类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UpdateContent

        private void UpdateContent()
        {
            if (panel == null)
                return;

            panel.Children.Clear();
            
            if (Value == null)
                return;
            
            var enumValues = Enum.GetValues(Value.GetType()).FilterOnBrowsableAttribute();
            var converter = new EnumToBooleanConverter { EnumType = Value.GetType() };
            var relativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(RadioButtonList), 1);
            var descriptionConverter = new EnumDescriptionConverter();

            foreach (var itemValue in enumValues )
            {
                var rb = new RadioButton { Content = descriptionConverter.Convert(itemValue, typeof(string), null, CultureInfo.CurrentCulture) };
                // rb.IsChecked = Value.Equals(itemValue);

                var isCheckedBinding = new Binding("Value")
                                           {
                                               Converter = converter,
                                               ConverterParameter = itemValue,
                                               Mode = BindingMode.TwoWay,
                                               RelativeSource = relativeSource
                                           };
                rb.SetBinding(ToggleButton.IsCheckedProperty, isCheckedBinding);

                var itemMarginBinding = new Binding("ItemMargin") { RelativeSource = relativeSource };
                rb.SetBinding(MarginProperty, itemMarginBinding);

                panel.Children.Add(rb);
            }
        }
开发者ID:hpbaotho,项目名称:sambapos,代码行数:35,代码来源:RadioButtonList.cs


示例2: InitializeGame

        /// <summary>
        /// Initialize game. Change "X" or "O". 
        /// </summary>
        private void InitializeGame()
        {
            Label label = new Label();
            label.Content = "Change:";
            label.FontSize = 20;
            label.Margin = new Thickness(0, 0, 0, 0);
            label.HorizontalAlignment = HorizontalAlignment.Left;
            label.VerticalAlignment = VerticalAlignment.Top;
            this.LayoutRoot.Children.Add(label);
            
            RadioButton[] whatYou = new RadioButton[2];
            whatYou[0] = new RadioButton();
            whatYou[1] = new RadioButton();
            whatYou[0].Content = "O";
            whatYou[1].Content = "X";
            whatYou[0].FontSize = whatYou[1].FontSize = 20;
            whatYou[0].Margin = new Thickness(10, 30, 0, 0);
            whatYou[1].Margin = new Thickness(50, 30, 0, 0);
            whatYou[0].IsChecked = true;
            whatYou[1].IsChecked = false;
            this.LayoutRoot.Children.Add(whatYou[0]);
            this.LayoutRoot.Children.Add(whatYou[1]);

            Button buttonOk = new Button();
            buttonOk.Content = "OK";
            buttonOk.Margin = new Thickness(0, 80, 0, 0);
            buttonOk.FontSize = 18;
            buttonOk.Width = 40;
            buttonOk.Height = 40;
            buttonOk.HorizontalAlignment = HorizontalAlignment.Left;
            buttonOk.VerticalAlignment = VerticalAlignment.Top;
            buttonOk.Click += new RoutedEventHandler(
                    (object sender, RoutedEventArgs e) => OnButtonOkClick((bool)whatYou[0].IsChecked));
            this.LayoutRoot.Children.Add(buttonOk);
        }
开发者ID:0x0all,项目名称:MyProgram,代码行数:38,代码来源:MainPage.xaml.cs


示例3: switch

 void IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
       {
     case 1:
       this.anonymousAccountRadioButton = (RadioButton) target;
       break;
     case 2:
       this.personalAccountRadioButton = (RadioButton) target;
       this.personalAccountRadioButton.Checked += new RoutedEventHandler(this.personalAccountRadioButton_Checked);
       break;
     case 3:
       ((UIElement) target).PreviewMouseDown += new MouseButtonEventHandler(this.TextBlock_MouseDown);
       break;
     case 4:
       this.usernameLabel = (Label) target;
       break;
     case 5:
       this.usernameTextBox = (TextBox) target;
       break;
     case 6:
       this.apiKeyLabel = (Label) target;
       break;
     case 7:
       this.apiKeyTextBox = (TextBox) target;
       break;
     default:
       this._contentLoaded = true;
       break;
       }
 }
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:31,代码来源:BitlyUISettings.xaml.cs


示例4: VariableUI

			public VariableUI(TextBlock label, TextBox value, Panel panel, RadioButton target)
			{
				Label = label;
				Value = value;
				Panel = panel;
				Target = target;
			}
开发者ID:,项目名称:,代码行数:7,代码来源:


示例5: OnEnumTypePropertyChanged

		static void OnEnumTypePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
		{
			Type enumType = e.NewValue as Type;
			if (enumType != null && enumType.IsEnum) {
				ComboBox comboBox = o as ComboBox;
				if (comboBox != null) {
					comboBox.SelectedValuePath = "Tag";
					comboBox.Items.Clear();
					foreach (FieldInfo field in enumType.GetFields()) {
						if (field.IsStatic) {
							ComboBoxItem item = new ComboBoxItem();
							item.Tag = field.GetValue(null);
							string description = GetDescription(field);
							item.SetValueToExtension(ComboBoxItem.ContentProperty, new StringParseExtension(description));
							comboBox.Items.Add(item);
						}
					}
				}
				RadioButtonGroup rbg = o as RadioButtonGroup;
				if (rbg != null) {
					rbg.Items.Clear();
					foreach (FieldInfo field in enumType.GetFields()) {
						if (field.IsStatic) {
							RadioButton b = new RadioButton();
							b.Tag = field.GetValue(null);
							string description = GetDescription(field);
							b.SetValueToExtension(RadioButton.ContentProperty, new StringParseExtension(description));
							rbg.Items.Add(b);
						}
					}
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:33,代码来源:EnumBinding.cs


示例6: treeView_New

        async void treeView_New()
        {
            slSecure.Web.SecureDBContext db;
            db = slSecure.DB.GetDB();
            TreeViewItem tvItem;

            var ERNameData = await db.LoadAsync<tblEngineRoomConfig>(db.GetTblEngineRoomConfigQuery());
            string sERName, sReadCardName, sControlID;
            foreach (var tempERNameData in ERNameData)
            {
                sERName = tempERNameData.ERName;
                tvItem = new TreeViewItem();
                tvItem.Header = sERName;

                foreach (var tempEntranceGuardData in tempERNameData.tblEntranceGuardConfig)
                {
                    foreach (var tempControllerConfigData in tempERNameData.tblControllerConfig)
                    {
                        if (tempControllerConfigData.EntranceCode == tempEntranceGuardData.EntranceCode && (tempControllerConfigData.ControlType == 1 || tempControllerConfigData.ControlType == 2))
                        {
                            sControlID = tempControllerConfigData.ControlID;
                            sReadCardName = tempEntranceGuardData.Memo;

                            RadioButton ck1 = new RadioButton() { Content = sReadCardName, Tag = sControlID, GroupName = "Door" };
                            tvItem.Items.Add(ck1);
                            tvItem.Tag = sControlID;
                        }
                    }
                }
                tv_TreeView_New.Items.Add(tvItem);
            }
        }
开发者ID:ufjl0683,项目名称:slSecureAndPD,代码行数:32,代码来源:slOpenDoor.xaml.cs


示例7: ColorPicker

 public ColorPicker(Dictionary<int, Color> colorByCode, int selectedColorIndex)
 {
     this.colorByCode = colorByCode;
     double colorPickerGridWidth = radioButtonSide * elements;
     ResourceDictionary dictionary = GetResourceDictionary();
     double autoColorRadioButtonHeight = 22;
     popupBorderBrush = GetEffectBorderBrush(colorPickerGridWidth -2,autoColorRadioButtonHeight-2, Colors.White, Colors.LightSlateGray);
     pressedBorderBrush = GetEffectBorderBrush(colorPickerGridWidth - 2, autoColorRadioButtonHeight-2, Colors.LightSlateGray, Colors.White);
     autoColorRadioButton = GetAutoColorRadioButton(dictionary["AutoColorElementTemplate"] as ControlTemplate, colorPickerGridWidth, autoColorRadioButtonHeight);
     Grid colorPickerGrid = GetColorPickerGrid(colorPickerGridWidth);
     Grid.SetRow(autoColorRadioButton, 0);
     Grid.SetColumn(autoColorRadioButton, 0);
     Grid.SetColumnSpan(autoColorRadioButton, elements);
     colorPickerGrid.Children.Add(autoColorRadioButton);
     ControlTemplate colorElementTemplate = dictionary["ColorElementTemplate"] as ControlTemplate;
     Color color;
     for (int colorIndex = 0; colorIndex <= colorByCode.Keys.Max<int>(); colorIndex++)
     {
         int rowIndex = (colorIndex / elements) + 1; // в первый ряд сетки уже добавлен элемент
         int columnIndex = colorIndex % elements;
         color = colorByCode[colorIndex];
         string tip = String.Format("{0} (#{1}{2}{3})", colorIndex, color.R.ToString("X2"), color.G.ToString("X2"), color.B.ToString("X2"));
         RadioButton radioButton = GetRadioButton(colorElementTemplate, ref color, colorIndex, tip);
         Grid.SetRow(radioButton, rowIndex);
         Grid.SetColumn(radioButton, columnIndex);
         colorPickerGrid.Children.Add(radioButton);
     }
     colorPickerGrid.Height = radioButtonSide * elements + autoColorRadioButton.Height + 2;
     gridBorder = GetGridBorder(colorPickerGrid);
     topButton = GetToggleButton(dictionary["ColorPickerTopButtonTemplate"] as ControlTemplate);
     colorPickerWindow = GetColorPickerWindow(gridBorder);
     SelectedColorIndex = selectedColorIndex;
     SetRadioButtonChecked(selectedColorIndex);
     Width = 150;
 }
开发者ID:Genotoxicity,项目名称:KSPE3Lib,代码行数:35,代码来源:ColorPicker.cs


示例8: btnOpen_Click

        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            //var dialog = new System.Windows.Forms.FolderBrowserDialog();

            //System.Windows.Forms.DialogResult result = dialog.ShowDialog();

            ////store the path to local storage

            //pathToMigrations = dialog.SelectedPath;
            pathToMigrations = @"d:\working\connect\scripts";
            migrator = MigratorFactory.GetMigrator(pathToMigrations);

            btnUp.DataContext = migrator.Tracker;
            btnDown.DataContext = migrator.Tracker;

            migrations = migrator.Tracker.Migrations;
            var version = migrator.Tracker.Version;
            stackPanel1.Children.Clear();
            foreach (var mig in migrations)
            {
                var rbl = new RadioButton();
                rbl.GroupName = "RBLMigration";
                rbl.Content = mig.Version;
                if (version == mig.Version)
                    rbl.IsChecked = true;
                rbl.Checked += new RoutedEventHandler(rbl_Checked);
                stackPanel1.Children.Add(rbl);
            }

            lblVersion.Content = version;
        }
开发者ID:soitgoes,项目名称:Mite,代码行数:31,代码来源:MainWindow.xaml.cs


示例9: ListInterfaces

        void ListInterfaces()
        {
            /* Retrieve the device list */
            var devices = CaptureDeviceList.Instance;

            /*If no device exists, print error */
            if (devices.Count < 1)
            {
                //string errorInfo = "No device found on this machine";
                TextBlock errorInfo = new TextBlock();
                errorInfo.Text = "No device found on this machine";
                this.StartButton.IsEnabled = false;
                this.Layout.Children.Add(errorInfo);
                return;
            }
            this.StartButton.IsEnabled = false;
            /* Scan the list printing every entry */
            foreach (var dev in devices)
            {
                /* Description */
                string interfaceInfo = dev.Description;
                RadioButton rb = new RadioButton();
                rb.Content = interfaceInfo;
                rb.Checked += new RoutedEventHandler(rb_Checked);
                this.InterfacesPanel.Children.Add(rb);
                //Console.WriteLine("{0}) {1} {2}", i, dev.Name, dev.Description);
            }
        }
开发者ID:2hanson,项目名称:sniffer,代码行数:28,代码来源:InterfacesListView.xaml.cs


示例10: SetScriptType

 private void SetScriptType(RadioButton radioButton)
 {
     if (radioButton.Name.Equals("Scheme"))
         scriptType = ScriptType.Scheme;
     else
         scriptType = ScriptType.Enumeration;
 }
开发者ID:Genotoxicity,项目名称:OutsideWiresSchema,代码行数:7,代码来源:UI.xaml.cs


示例11: setUpValues

        private void setUpValues()
        {
            this.country.ItemsSource = Enum.GetNames(typeof(Interface.Countries));
            
            foreach (string e in Enum.GetNames(typeof(Interface.CorporatePerson)))
            {
                RadioButton b = new RadioButton();
                b.Content = e == "PO" ? "Podnikateľ" : e == "FOP" ? "Živnostník" : "Nepodnikateľ";
                b.Width = 130;
                b.Name = e;
                b.VerticalAlignment = VerticalAlignment.Center;
                b.Checked += this.onChangeCorpPers_Checked;
                this.corporatePersonStack.Children.Add(b);
            }
            Interface.ICompany cmp = this._temp.company;
            this.customId.Text = cmp.custom_id;
            this.name.Text = cmp.name;
            this.ico.Text = cmp.ico;
            this.dic.Text = cmp.dic;
            this.icDph.Text = cmp.icDph;
            foreach (RadioButton rb in this.corporatePersonStack.Children)
                rb.IsChecked = cmp.corporatePerson.ToString() == rb.Name ? true : false;

            customId.Text = this._temp.company.custom_id;
            titlePrefix.Text=this._temp.company.person.titlePrefix;
           firstName.Text=this._temp.company.person.firstName;
            lastName.Text=this._temp.company.person.lastName;
             titleSuffix.Text=this._temp.company.person.titleSuffix;
            street.Text=this._temp.company.address.street;
             city.Text=this._temp.company.address.city;
          zip.Text=this._temp.company.address.zip;
            country.Text=this._temp.company.address.country;
        email.Text=this._temp.company.contact.email;
          mobile.Text=this._temp.company.contact.mobile;
        }
开发者ID:Tabetha,项目名称:SchoolHellCoders,代码行数:35,代码来源:OrderEditControl.xaml.cs


示例12: bind

 private void bind(PropertyItem propertyItem, RadioButton btnTopLeft, Anchor anchor)
 {
     BindingOperations.SetBinding(btnTopLeft, ToggleButton.IsCheckedProperty, LambdaBinding.New(
         new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay },
         (object source) => { return (Anchor) source == anchor; },
         (bool source) => { return source ? anchor : Binding.DoNothing; }
     ));
 }
开发者ID:rstarkov,项目名称:TankIconMaker,代码行数:8,代码来源:AnchorEditor.xaml.cs


示例13: RadioButtonAutomationPeer

		public RadioButtonAutomationPeer (RadioButton owner)
			: base (owner)
		{
			isSelected = IsSelected;

			// UIA Event SelectionItemPatternIdentifiers.IsSelectedProperty
			// raised by ToggleButton.OnIsCheckedPropertyChanged().
		}
开发者ID:shana,项目名称:moon,代码行数:8,代码来源:RadioButtonAutomationPeer.cs


示例14: GroupNameNoParent

		public void GroupNameNoParent()
		{
			var b1 = new RadioButton { GroupName = "AA" };
			var b2 = new RadioButton { GroupName = "AA" };

			b1.IsChecked = true;
			b2.IsChecked = true;
			Assert.IsTrue((bool)b1.IsChecked, "#2");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:RadioButtonTest.cs


示例15: InitializeComponent

 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/CodeCamp.RIA.UI;component/Controls/PreferenceValueRadioButton.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.TheButton = ((System.Windows.Controls.RadioButton)(this.FindName("TheButton")));
 }
开发者ID:onetug,项目名称:CodeCamp2011,代码行数:9,代码来源:PreferenceValueRadioButton.g.i.cs


示例16: CreateRadioButton

 RadioButton CreateRadioButton(string strText, WindowStyle winstyle)
 {
     RadioButton radio = new RadioButton();
     radio.Content = strText;
     radio.Tag = winstyle;
     radio.Margin = new Thickness(5);
     radio.IsChecked = (winstyle == WindowStyle);
     return radio;
 }
开发者ID:JianchengZh,项目名称:kasicass,代码行数:9,代码来源:TuneTheRadio.cs


示例17: switch

 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.button = ((System.Windows.Controls.RadioButton)(target));
     return;
     }
     this._contentLoaded = true;
 }
开发者ID:TrackerForever,项目名称:psd-thumbnail-codec,代码行数:9,代码来源:CommandLinkWPF.g.i.cs


示例18: InitializeComponent

 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/UISample;component/HighlightButton.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.button = ((System.Windows.Controls.RadioButton)(this.FindName("button")));
 }
开发者ID:mylgoehy,项目名称:qlqtpmav10,代码行数:9,代码来源:HighlightButton.g.cs


示例19: DeselectAllOtherItems

        private void DeselectAllOtherItems(RadioButton currentRadioButton)
        {
            if (currentRadioButton.IsChecked != true) return;

            var children = this.DataControl.ChildrenOfType<RadioButton>();

            foreach (var radioButton in children.Where(rb => rb != currentRadioButton))
                radioButton.IsChecked = false;
        }
开发者ID:FoundOPS,项目名称:server,代码行数:9,代码来源:EditRadioButtonColumn.cs


示例20: InitializeComponent

 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/Segator.Loms.Modules.Bookings.Silverlight;component/Silverlight/Views/GetQuote/C" +
                 "ityOfServiceView.xaml", System.UriKind.Relative));
     this.SelectByCityName = ((System.Windows.Controls.RadioButton)(this.FindName("SelectByCityName")));
     this.SelectByStateName = ((System.Windows.Controls.RadioButton)(this.FindName("SelectByStateName")));
 }
开发者ID:felixthehat,项目名称:Limo,代码行数:10,代码来源:CityOfServiceView.g.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.RichTextBox类代码示例发布时间:2022-05-26
下一篇:
C# Controls.ProgressBar类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap