本文整理汇总了C#中System.Windows.Controls.Primitives.ToggleButton.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ToggleButton.SetBinding方法的具体用法?C# ToggleButton.SetBinding怎么用?C# ToggleButton.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Primitives.ToggleButton
的用法示例。
在下文中一共展示了ToggleButton.SetBinding方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindTheButton
public BindTheButton()
{
Title = "Bind The Button";
ToggleButton btn = new ToggleButton();
btn.Content = "Make _Topmost";
btn.HorizontalAlignment = HorizontalAlignment.Center;
btn.VerticalAlignment = VerticalAlignment.Center;
btn.SetBinding(ToggleButton.IsCheckedProperty, "Topmost");
btn.DataContext = this;
Content = btn;
ToolTip tip = new ToolTip();
tip.Content = "Toggle the button on to make the window topmost on the desktop";
btn.ToolTip = tip;
}
示例2: SetDefaultWindowData
private void SetDefaultWindowData()
{
Title = "Bind the Button";
ToggleButton toggleButton = new ToggleButton();
toggleButton.Content = "Make _TopMost";
//toggleButton.HorizontalAlignment = HorizontalAlignment.Center;
//toggleButton.VerticalAlignment = VerticalAlignment.Center;
// **
toggleButton.SetBinding(ToggleButton.IsCheckedProperty, "TopMost");
toggleButton.DataContext = this;
Content = toggleButton;
ToolTip tip = new ToolTip();
// tooltip의 content에 image를 적용 시킬 수 있다.
tip.Content = "Toggle the button on the make the window top most on the desktop";
toggleButton.ToolTip = tip;
}
示例3: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (_toggleButton != null)
{
_toggleButton.Checked -= CheckedHandler;
_toggleButton.Unchecked -= UncheckedHandler;
_toggleButton.Indeterminate -= IndeterminateHandler;
_toggleButton.Click -= ClickHandler;
BindingOperations.ClearBinding(_toggleButton, ToggleButton.IsCheckedProperty);
_toggleButton.IsEnabledChanged -= IsEnabledHandler;
_toggleButton.PreviewMouseUp -= this.ToggleButtonPreviewMouseUp;
}
_toggleButton = GetTemplateChild(SwitchPart) as ToggleButton;
if (_toggleButton != null)
{
_toggleButton.Checked += CheckedHandler;
_toggleButton.Unchecked += UncheckedHandler;
_toggleButton.Indeterminate += IndeterminateHandler;
_toggleButton.Click += ClickHandler;
var binding = new Binding("IsChecked") { Source = this };
_toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding);
_toggleButton.IsEnabledChanged += IsEnabledHandler;
_toggleButton.PreviewMouseUp += this.ToggleButtonPreviewMouseUp;
}
ChangeVisualState(false);
}
示例4: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (!_wasContentSet && GetBindingExpression(ContentProperty) == null)
{
SetDefaultContent();
}
if (_toggleButton != null)
{
_toggleButton.Checked -= CheckedHandler;
_toggleButton.Unchecked -= UncheckedHandler;
_toggleButton.Indeterminate -= IndeterminateHandler;
_toggleButton.Click -= ClickHandler;
BindingOperations.ClearBinding(_toggleButton, ToggleButton.IsCheckedProperty);
_toggleButton.IsEnabledChanged -= IsEnabledHandler;
}
_toggleButton = GetTemplateChild(SwitchPart) as ToggleButton;
if (_toggleButton != null)
{
_toggleButton.Checked += CheckedHandler;
_toggleButton.Unchecked += UncheckedHandler;
_toggleButton.Indeterminate += IndeterminateHandler;
_toggleButton.Click += ClickHandler;
var binding = new Binding("IsChecked") { Source = this };
_toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding);
_toggleButton.IsEnabledChanged += IsEnabledHandler;
}
ChangeVisualState(false);
}
示例5: grid_LoadedRowHeaderPresenter
private void grid_LoadedRowHeaderPresenter(object sender, C1.WPF.DataGrid.DataGridRowEventArgs e)
{
var task = e.Row.DataItem as Task;
var rowHeaderPresenter = e.Row.HeaderPresenter;
if (task.SubTasks.Count > 0)
{
var toggleButton = new ToggleButton();
toggleButton.Style = Resources["TButtonStyle"] as Style;
toggleButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsExpanded")
{
Source = task,
Mode = BindingMode.TwoWay
});
toggleButton.IsThreeState = false;
toggleButton.Tag = task;
rowHeaderPresenter.Content = toggleButton;
}
else
{
rowHeaderPresenter.Content = null;
}
}
示例6: CreateFavoriteButton
public ToggleButton CreateFavoriteButton(Status s)
{
ToggleButton b = new ToggleButton ();
Binding fontSizeBinding = CreateBinding (this, FontSizeProperty.Name, BindingMode.OneWay);
b.SetBinding (ToggleButton.WidthProperty, fontSizeBinding);
b.SetBinding (ToggleButton.HeightProperty, fontSizeBinding);
Binding favBinding = CreateBinding (s, "IsFavorited", BindingMode.OneWay);
b.SetBinding (ToggleButton.IsCheckedProperty, favBinding);
b.Margin = new Thickness (0, 0, 3, 0);
b.VerticalAlignment = VerticalAlignment.Center;
b.Click += isFav_Click;
b.Style = (Style)Resources["favoriteButton"];
return b;
}
示例7: ChildrenAddHandler
public void ChildrenAddHandler(Object sender, RoutedEventArgs evt)
{
FrameworkElement newChild = (FrameworkElement)evt.OriginalSource;
this.Children.Remove(newChild);
contentBox.Visibility = Visibility.Visible;
contentBox.Width = 0;
//buttonsDockPanel.Width = BUTTON_BAR_WIDTH;
buttonsDockPanel.Visibility = Visibility.Visible;
ToggleButton newButton = new ToggleButton();
if (this.FindResource("ButtonBarTemplate") is ControlTemplate)
newButton.Template = (ControlTemplate)this.FindResource("ButtonBarTemplate");
newButton.Height = 30;
newButton.Margin = new Thickness(0, 0.5, 0, 0.5);
newButton.Foreground = Brushes.White;
newButton.FontSize = 14;
Binding b = new Binding();
b.Source = newChild;
b.Path = new PropertyPath(PlayerContentPanel.ButtonsNameProperty);
newButton.SetBinding(ToggleButton.ContentProperty, b);
newButton.Click += new RoutedEventHandler(buttons_Click);
buttonsDockPanel.Children.Add(newButton);
newButton.VerticalAlignment = VerticalAlignment.Top;
newButton.HorizontalAlignment = HorizontalAlignment.Stretch;
DockPanel.SetDock(newButton, Dock.Top);
this.buttonControlMapping.Add(newButton, newChild);
}