本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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++;
}
}
}
示例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;
}
示例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)
});
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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();
}
示例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;
}