本文整理汇总了C#中System.Windows.Controls.Primitives.ToggleButton类的典型用法代码示例。如果您正苦于以下问题:C# ToggleButton类的具体用法?C# ToggleButton怎么用?C# ToggleButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToggleButton类属于System.Windows.Controls.Primitives命名空间,在下文中一共展示了ToggleButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Attach
protected override void Attach()
{
_control = (ToggleButton)ControlObject;
_control.Checked += ChangeCheck;
_control.Unchecked += ChangeCheck;
_control.Indeterminate += ChangeCheck;
}
示例2: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.button = (ToggleButton)this.GetTemplateChild("PART_ToggleDropDown");
this.popup = (Popup)this.GetTemplateChild("PART_Popup");
this.content = (ContentControl)this.GetTemplateChild("PART_Content");
this.SizeChanged += this.DropDownButton_SizeChanged;
#if(SILVERLIGHT)
UIElement root = Application.Current.RootVisual;
if (root != null)
{
root.MouseLeftButtonDown += (s, ee) =>
{
if (popup.IsOpen)
popup.IsOpen = false;
};
}
#endif
#if (!SILVERLIGHT)
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
{
System.Windows.Window window = System.Windows.Window.GetWindow(this);
window.LocationChanged += window_LocationChanged;
window.SizeChanged += window_SizeChanged;
LayoutUpdated += DropDownButton_LayoutUpdated;
}
popup.Opened += popup_Opened;
popup.IsKeyboardFocusWithinChanged += popup_IsKeyboardFocusWithinChanged;
FindTopLevelElement(popup).MouseDown += Outside_MouseDown;
#endif
}
示例3: AddToggleEvent
static void AddToggleEvent(ToggleButton toggle)
{
toggle.Checked += delegate
{
MessageBox.Show("");
};
}
示例4: OnApplyTemplate
public override void OnApplyTemplate()
{
if (SymbolOverlay != null)
SymbolOverlay.MouseLeftButtonUp -= SymbolOverlay_MouseLeftButtonUp;
if (SymbolSelector != null)
SymbolSelector.SymbolSelected -= SymbolSelector_SymbolSelected;
base.OnApplyTemplate();
SymbolSelector = GetTemplateChild("SymbolSelector") as SymbolSelector;
if (SymbolSelector != null)
SymbolSelector.SymbolSelected += SymbolSelector_SymbolSelected;
UniqueValueTextBlock = GetTemplateChild("UniqueValueTextBlock") as TextBlock;
ToggleButton = GetTemplateChild("ToggleButton") as ToggleButton;
SymbolDisplay = GetTemplateChild("SymbolDisplay") as SymbolDisplay;
SymbolOverlay = GetTemplateChild("SymbolOverlay") as Rectangle;
if (SymbolOverlay != null)
SymbolOverlay.MouseLeftButtonUp += SymbolOverlay_MouseLeftButtonUp;
if (InitCompleted != null)
InitCompleted(this, EventArgs.Empty);
}
示例5: InitializeChildrens
void InitializeChildrens() {
if (expander != null)
return;
ToolTip = toolTipDummy;
expander = new ToggleButton {
Style = (Style)FindResource("ExpandCollapseToggleStyle")
};
icon = new Image {
Width = 16,
Height = 16,
Margin = new Thickness(0, 0, 5, 1),
VerticalAlignment = VerticalAlignment.Center,
Focusable = false
};
content = new ContentPresenter {
Margin = new Thickness(2, 0, 6, 0),
VerticalAlignment = VerticalAlignment.Center,
Focusable = false
};
expander.Checked += (sender, e) => Node.IsExpanded = true;
expander.Unchecked += (sender, e) => Node.IsExpanded = false;
AddVisualChild(expander);
AddVisualChild(icon);
AddVisualChild(content);
UpdateChildren(Node);
}
示例6: CheckToggleButton
public static void CheckToggleButton(ToggleButton control, bool check)
{
if (control != null)
{
control.IsChecked = new bool?(check);
}
}
示例7: ToggleButtonPropertyBinding
/// <summary>
/// Constructs a new toggle button property binding for the given toggle button.
/// </summary>
/// <param name="tglButton">The toggle button to be bound to the property.</param>
protected ToggleButtonPropertyBinding(ToggleButton tglButton)
: base(tglButton)
{
tglButton.Checked += OnStateChanged;
tglButton.Unchecked += OnStateChanged;
tglButton.Indeterminate += OnStateChanged;
}
示例8: IsOn
private bool IsOn(ToggleButton tb)
{
var res = Segment7.FindChild<ToggleButton>(tb.Name);
if (res == null) res = Segment14.FindChild<ToggleButton>(tb.Name);
if (res == null) throw new ArgumentException("Not found");
else return (bool)res.IsChecked;
}
示例9: SetOption
private static void SetOption(ToggleButton cb, ref List<string> currentOption, string option)
{
if (cb.IsChecked.HasValue && cb.IsChecked.Value)
{
currentOption.Add(option);
}
}
示例10: ToggleButtonUndoOperation
public ToggleButtonUndoOperation(ToggleButton sender, bool? oldValue, bool? newValue)
{
Sender = sender;
OldValue = oldValue;
NewValue = newValue;
Timestamp = DateTime.UtcNow;
}
示例11: DateTimePartHelper
public DateTimePartHelper(DateTime dateTime, DateTimePart dateTimePart, NumericTextBox textBox, ToggleButton activeToggleButton)
{
_dateTime = dateTime;
_textBox = textBox;
_toggleButton = activeToggleButton;
_dateTimePart = dateTimePart;
}
示例12: AttachButton
static void AttachButton(ToggleButton trigger)
{
// When the ToggleButton is checked, execute the folowing code
trigger.Checked +=
delegate
{
// Uncheck the previous button if there is one
//if (ActiveButtons != null) ActiveButtons.IsChecked = false;
// This button is now the active button
//ActiveButton = trigger;
ActiveButtons.Add(trigger);
// The list is changed, so envoke the ActiveButtonsChanged event
ActiveButtonsChanged(null, EventArgs.Empty);
};
// When the ToggleButton is unchecked, execute the folowing code
trigger.Unchecked +=
delegate
{
// There is no active button annymore
//ActiveButtons = null;
ActiveButtons.Remove(trigger);
// The list is changed, so envoke the ActiveButtonsChanged event
ActiveButtonsChanged(null, EventArgs.Empty);
};
}
示例13: InitializeComponent
public void InitializeComponent()
{
if (!this._contentLoaded)
{
this._contentLoaded = true;
Application.LoadComponent(this, new Uri("/TWC.OVP;component/Views/Shell/SportsNetworkShellView.xaml", UriKind.Relative));
this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
this.ControllerStates = (VisualStateGroup) base.FindName("ControllerStates");
this.ShowController = (VisualState) base.FindName("ShowController");
this.HideController = (VisualState) base.FindName("HideController");
this.WindowStates = (VisualStateGroup) base.FindName("WindowStates");
this.FullScreen = (VisualState) base.FindName("FullScreen");
this.Embedded = (VisualState) base.FindName("Embedded");
this.CaptionSettingsStates = (VisualStateGroup) base.FindName("CaptionSettingsStates");
this.ShowCaptionSettings = (VisualState) base.FindName("ShowCaptionSettings");
this.HideCaptionSettings = (VisualState) base.FindName("HideCaptionSettings");
this.BackgroundRectangle = (Rectangle) base.FindName("BackgroundRectangle");
this.AssetViewer = (ContentControl) base.FindName("AssetViewer");
this.Controller = (Grid) base.FindName("Controller");
this.volumeControl = (VolumeControl) base.FindName("volumeControl");
this.ClosedCaptioning = (ToggleButton) base.FindName("ClosedCaptioning");
this.FullScreenGrid = (Grid) base.FindName("FullScreenGrid");
this.FullScreenButton = (Button) base.FindName("FullScreenButton");
this.ExitFullScreenGrid = (Grid) base.FindName("ExitFullScreenGrid");
this.ExitFullScreenButton = (Button) base.FindName("ExitFullScreenButton");
this.Interaction = (ContentControl) base.FindName("Interaction");
}
}
示例14: GaneralLeds
public GaneralLeds(ToggleButton[] debugarray, Image[] debugtxtarray, ToggleButton[] common, Image[] commontxtarray, ToggleButton[] leds, Image[] ledstxtarray, ToggleButton[] modems, Image[] modemstxtarray)
{
Debug = new bool[debugarray.Length];
Common = new bool[common.Length];
Leds = new bool[leds.Length];
Modems = new bool[modems.Length];
Debugtxt = debugtxtarray;
Debugbtn = debugarray;
Commonbtn = common;
Commontxt = commontxtarray;
Ledsbtn = leds;
Ledstxt = ledstxtarray;
Modembtn = modems;
Modemtxt = modemstxtarray;
foreach (ToggleButton item in Debugbtn)
{
item.Click += new System.Windows.RoutedEventHandler(Clicked);
}
foreach (ToggleButton item in Commonbtn)
{
item.Click += new System.Windows.RoutedEventHandler(Clicked);
}
foreach (ToggleButton item in Ledsbtn)
{
item.Click += new System.Windows.RoutedEventHandler(Clicked);
}
foreach (ToggleButton item in Modembtn)
{
item.Click += new System.Windows.RoutedEventHandler(Clicked);
}
}
示例15: 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;
}