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


C# CheckBox.SetBinding方法代码示例

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


在下文中一共展示了CheckBox.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCheckBox

 private CheckBox CreateCheckBox(object source, string propertyName)
 {
     CheckBox checkBox = new CheckBox();
     Binding bd = new System.Windows.Data.Binding(propertyName);
     bd.Mode = BindingMode.TwoWay;
     bd.Source = source;
     checkBox.SetBinding(CheckBox.IsCheckedProperty, bd);
     return checkBox;
 }
开发者ID:vesteksoftware,项目名称:VT8642,代码行数:9,代码来源:WindowOptionWarning.xaml.cs

示例2: CreateCheckBox

        /// <summary>
        /// Creates a CheckBox for switch parameters
        /// </summary>
        /// <param name="parameterViewModel">DataContext object</param>
        /// <param name="rowNumber">Row number</param>
        /// <returns>a CheckBox for switch parameters</returns>
        private static CheckBox CreateCheckBox(ParameterViewModel parameterViewModel, int rowNumber)
        {
            CheckBox checkBox = new CheckBox();

            checkBox.SetBinding(Label.ContentProperty, new Binding("NameCheckLabel"));
            checkBox.DataContext = parameterViewModel;
            checkBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            checkBox.SetValue(Grid.ColumnProperty, 0);
            checkBox.SetValue(Grid.ColumnSpanProperty, 2);
            checkBox.SetValue(Grid.RowProperty, rowNumber);
            checkBox.IsThreeState = false;
            checkBox.Margin = new Thickness(8, rowNumber == 0 ? 7 : 5, 0, 5);
            checkBox.SetBinding(CheckBox.ToolTipProperty, new Binding("ToolTip"));
            Binding valueBinding = new Binding("Value");
            checkBox.SetBinding(CheckBox.IsCheckedProperty, valueBinding);

            //// Add AutomationProperties.AutomationId for Ui Automation test.
            checkBox.SetValue(
                System.Windows.Automation.AutomationProperties.AutomationIdProperty,
                string.Format(CultureInfo.CurrentCulture, "chk{0}", parameterViewModel.Name));

            checkBox.SetValue(
                System.Windows.Automation.AutomationProperties.NameProperty,
                parameterViewModel.Name);

            return checkBox;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:33,代码来源:ParameterSetControl.xaml.cs

示例3: SimpleUIBoundToCustomer

        public SimpleUIBoundToCustomer()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LstName")); //purposefully misspelled
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding()); //context
            stack.Children.Add(textBlock);

            var checkbox = new CheckBox();
            checkbox.SetBinding(CheckBox.IsCheckedProperty, new Binding("asdfsdf")); //does not exist
            stack.Children.Add(checkbox);

            var tooltip = new ToolTip();
            tooltip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, new Binding("asdfasdasdf")); // does not exist
            stack.ToolTip = tooltip;

            var childUserControl = new SimpleUIBoundToCustomerByAttachedPorperty();
            stack.Children.Add(childUserControl);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:28,代码来源:SimpleUIBoundToCustomer.cs

示例4: OnFlagTypeChanged

        static void OnFlagTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Type flagType = args.NewValue as Type;
            Fx.Assert(flagType == null || flagType.IsEnum, "FlagType should be null or enum");
            Fx.Assert(flagType == null || Attribute.IsDefined(flagType, typeof(FlagsAttribute)), "FlagType should be null or have flags attribute");

            if (flagType == null)
            {
                return;
            }

            int index = 0;
            FlagPanel panel = sender as FlagPanel;
            string[] flagNames = flagType.GetEnumNames();
            string zeroValueString = Enum.ToObject(flagType, 0).ToString();
            foreach (string flagName in flagNames)
            {
                if (zeroValueString.Equals("0") || !flagName.Equals(zeroValueString))
                {
                    CheckBox checkBox = new CheckBox();
                    panel.Children.Add(checkBox);
                    checkBox.Content = flagName;
                    checkBox.DataContext = panel;
                    checkBox.SetValue(AutomationProperties.AutomationIdProperty, flagName);
                    Binding binding = new Binding("FlagString");
                    binding.Mode = BindingMode.TwoWay;
                    binding.Converter = new CheckBoxStringConverter(index);
                    binding.ConverterParameter = panel;
                    checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
                    index++;
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:33,代码来源:FlagPanel.cs

示例5: build_lblcb

        private StackPanel build_lblcb(string text, string property)
        {
            TextBlock tb = new TextBlock();
            tb.Text = text;
            tb.TextAlignment = TextAlignment.Right;
            tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            tb.Width = 55;
            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;

            CheckBox cb = new CheckBox();
            cb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            Binding bind = new Binding(property);
            cb.SetBinding(CheckBox.IsCheckedProperty, bind);
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();
            mySolidColorBrush.Color = Color.FromArgb(255, 51, 51, 51);
            cb.Background = mySolidColorBrush;
            SolidColorBrush mySolidColorBrush2 = new SolidColorBrush();
            mySolidColorBrush2.Color = Color.FromArgb(255, 112, 112, 112);
            cb.BorderBrush = mySolidColorBrush2;
            //Background="#FF333333" BorderBrush="#FF707070"

            sp.Height = 25;
            sp.Children.Add(tb);
            sp.Children.Add(cb);
            return sp;
        }
开发者ID:mario007,项目名称:renmas,代码行数:27,代码来源:options_editor.xaml.cs

示例6: BindToOption

 protected void BindToOption(CheckBox checkBox, object source, string propertyName)
 {
     checkBox.SetBinding(ToggleButton.IsCheckedProperty, new System.Windows.Data.Binding
     {
         Source = source,
         Path = new PropertyPath(propertyName)
     });
 }
开发者ID:tgjones,项目名称:HlslTools,代码行数:8,代码来源:OptionsControlBase.cs

示例7: LoadUI

        public override FrameworkElement LoadUI(Option option)
        {
            if (_checkBox != null) return _checkBox;

            _checkBox = new CheckBox { DataContext = this, Content = _content ?? option.DisplayName };
            _checkBox.SetBinding(ToggleButton.IsCheckedProperty, "CurrentValue");

            return _checkBox;
        }
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:9,代码来源:CheckBoxHelper.cs

示例8: BindToOption

        protected void BindToOption(CheckBox checkbox, PerLanguageOption<bool> optionKey, string languageName)
        {
            Binding binding = new Binding();

            binding.Source = new PerLanguageOptionBinding<bool>(OptionService, optionKey, languageName);
            binding.Path = new PropertyPath("Value");
            binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;

            var bindingExpression = checkbox.SetBinding(CheckBox.IsCheckedProperty, binding);
            _bindingExpressions.Add(bindingExpression);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:AbstractOptionPageControl.cs

示例9: BindToOption

        protected void BindToOption(CheckBox checkbox, Option<bool> optionKey)
        {
            var binding = new Binding()
            {
                Source = new OptionBinding<bool>(OptionService, optionKey),
                Path = new PropertyPath("Value"),
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            var bindingExpression = checkbox.SetBinding(CheckBox.IsCheckedProperty, binding);
            _bindingExpressions.Add(bindingExpression);
        }
开发者ID:gnuhub,项目名称:roslyn,代码行数:12,代码来源:AbstractOptionPageControl.cs

示例10: GetGeneratedContent

        /// <summary>
        /// Generate content for cell by column binding
        /// </summary>
        /// <returns>Checkbox element</returns>
        internal override FrameworkElement GetGeneratedContent()
        {
            CheckBox result = new CheckBox();

            if (this.Binding != null)
            {
                result.SetBinding(CheckBox.IsCheckedProperty, this.Binding);
            }

            result.SetValue(CheckBox.HorizontalAlignmentProperty, HorizontalAlignment.Center);

            return result;
        }
开发者ID:AlexanderShniperson,项目名称:GridView4WP7,代码行数:17,代码来源:GridViewCheckboxColumn.cs

示例11: CreateBoundCheckBox

            private CheckBox CreateBoundCheckBox(string content, object source, string sourcePropertyName)
            {
                var cb = new CheckBox { Content = content };

                var binding = new Binding()
                {
                    Source = source,
                    Path = new PropertyPath(sourcePropertyName)
                };

                base.AddBinding(cb.SetBinding(CheckBox.IsCheckedProperty, binding));

                return cb;
            }
开发者ID:RoryVL,项目名称:roslyn,代码行数:14,代码来源:InternalFeaturesOnOffPage.cs

示例12: Display

		public static void Display(DecompilerTextView textView) {
			AvalonEditTextOutput output = new AvalonEditTextOutput();
			output.WriteLine(string.Format("dnSpy version {0}", currentVersion.ToString()), TextTokenType.Text);
			var decVer = typeof(ICSharpCode.Decompiler.Ast.AstBuilder).Assembly.GetName().Version;
			output.WriteLine(string.Format("ILSpy Decompiler version {0}.{1}.{2}", decVer.Major, decVer.Minor, decVer.Build), TextTokenType.Text);
			if (checkForUpdateCode)
				output.AddUIElement(
					delegate {
						StackPanel stackPanel = new StackPanel();
						stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
						stackPanel.Orientation = Orientation.Horizontal;
						if (latestAvailableVersion == null) {
							AddUpdateCheckButton(stackPanel, textView);
						}
						else {
						// we already retrieved the latest version sometime earlier
						ShowAvailableVersion(latestAvailableVersion, stackPanel);
						}
						CheckBox checkBox = new CheckBox();
						checkBox.Margin = new Thickness(4);
						checkBox.Content = "Automatically check for updates every week";
						UpdateSettings settings = new UpdateSettings(DNSpySettings.Load());
						checkBox.SetBinding(CheckBox.IsCheckedProperty, new Binding("AutomaticUpdateCheckEnabled") { Source = settings });
						return new StackPanel {
							Margin = new Thickness(0, 4, 0, 0),
							Cursor = Cursors.Arrow,
							Children = { stackPanel, checkBox }
						};
					});
			if (checkForUpdateCode)
				output.WriteLine();
			foreach (var plugin in App.CompositionContainer.GetExportedValues<IAboutPageAddition>())
				plugin.Write(output);
			output.WriteLine();
			using (Stream s = typeof(AboutPage).Assembly.GetManifestResourceStream(typeof(dnSpy.StartUpClass), "README.txt")) {
				using (StreamReader r = new StreamReader(s)) {
					string line;
					while ((line = r.ReadLine()) != null) {
						output.WriteLine(line, TextTokenType.Text);
					}
				}
			}
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("SharpDevelop", "http://www.icsharpcode.net/opensource/sd/"));
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("MIT License", "resource:license.txt"));
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("LGPL", "resource:LGPL.txt"));
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("COPYING", "resource:COPYING"));
			textView.ShowText(output);
			MainWindow.Instance.SetTitle(textView, "About");
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:49,代码来源:AboutPage.cs

示例13: CreateToolbarItem

		public object CreateToolbarItem() {
			var checkBox = new CheckBox() {
				Content = new Image {
					Width = 16,
					Height = 16,
					Source = ImageCache.Instance.GetImage("PrivateInternal", BackgroundType.Toolbar),
				},
				ToolTip = "Show Internal Types and Members",
			};
			var binding = new Binding("FilterSettings.ShowInternalApi") {
				Source = MainWindow.Instance.SessionSettings,
			};
			checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
			return checkBox;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:15,代码来源:ToolbarCommands.cs

示例14: Display

		public static void Display(DecompilerTextView textView)
		{
			AvalonEditTextOutput output = new AvalonEditTextOutput();
			output.WriteLine("ILSpy version " + RevisionClass.FullVersion);
			output.AddUIElement(
				delegate {
					StackPanel stackPanel = new StackPanel();
					stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
					stackPanel.Orientation = Orientation.Horizontal;
					if (latestAvailableVersion == null) {
						AddUpdateCheckButton(stackPanel, textView);
					} else {
						// we already retrieved the latest version sometime earlier
						ShowAvailableVersion(latestAvailableVersion, stackPanel);
					}
					CheckBox checkBox = new CheckBox();
					checkBox.Margin = new Thickness(4);
					checkBox.Content = "Automatically check for updates every week";
					UpdateSettings settings = new UpdateSettings(ILSpySettings.Load());
					checkBox.SetBinding(CheckBox.IsCheckedProperty, new Binding("AutomaticUpdateCheckEnabled") { Source = settings });
					return new StackPanel {
						Margin = new Thickness(0, 4, 0, 0),
						Cursor = Cursors.Arrow,
						Children = { stackPanel, checkBox }
					};
				});
			output.WriteLine();
			foreach (var plugin in App.CompositionContainer.GetExportedValues<IAboutPageAddition>())
				plugin.Write(output);
			output.WriteLine();
			using (Stream s = typeof(AboutPage).Assembly.GetManifestResourceStream(typeof(AboutPage), "README.txt")) {
				using (StreamReader r = new StreamReader(s)) {
					string line;
					while ((line = r.ReadLine()) != null) {
						output.WriteLine(line);
					}
				}
			}
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("SharpDevelop", "http://www.icsharpcode.net/opensource/sd/"));
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("MIT License", "resource:license.txt"));
			output.AddVisualLineElementGenerator(new MyLinkElementGenerator("LGPL", "resource:LGPL.txt"));
			textView.ShowText(output);
			
			//reset icon bar
			textView.manager.Bookmarks.Clear();
		}
开发者ID:Netring,项目名称:ILSpy,代码行数:46,代码来源:AboutPage.cs

示例15: CreateToolbarItem

		public object CreateToolbarItem() {
			var sp = new StackPanel {
				Orientation = Orientation.Horizontal,
				ToolTip = "Full Screen",
			};
			sp.Children.Add(new Image {
				Width = 16,
				Height = 16,
				Source = ImageCache.Instance.GetImage("FullScreen", BackgroundType.ToolBarButtonChecked),
			});
			sp.Children.Add(new TextBlock {
				Text = "Full Screen",
				Margin = new Thickness(5, 0, 0, 0),
			});
			var checkBox = new CheckBox { Content = sp };
			var binding = new Binding("IsFullScreen") {
				Source = MainWindow.Instance,
			};
			checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
			return checkBox;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:21,代码来源:ToolbarCommands.cs


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