FlipSwitch Class
Represents a flip switch control.
public class FlipSwitch : CircularGaugeBase, ILogicalParent, IVisualParent
- Inheritance:
- object Visual UIElement FrameworkElement GaugeElement GaugeBase CircularGaugeBase object
- Implements:
- ILogicalParent IVisualParent
Remarks
For detailed documentation on this control's features and how to use them, please see the Gauge documentation topics.
Constructors
FlipSwitch()
Initializes a new instance of the FlipSwitch class.
public FlipSwitch()
Properties
BallBrush
Gets or sets the brush used to render the ball of the switch. This is a dependency property.
public Brush BallBrush { get; set; }
Property Value
- Brush:
The brush used to render the ball of the switch. The default value is
DarkGray
.
BaseAccentBrush
Gets or sets the brush used to render the accent shape on the base. This is a dependency property.
public Brush BaseAccentBrush { get; set; }
Property Value
- Brush:
The brush used to render the accent shape on the base. The default value is
Black
.
BaseBackground
Gets or sets the brush used to render the base background. This is a dependency property.
public Brush BaseBackground { get; set; }
Property Value
- Brush:
The brush used to render the base background. The default value is
DarkGray
.
FocusBrush
Gets or sets brush used to render the focus indicator. This is a dependency property.
public Brush FocusBrush { get; set; }
Property Value
- Brush:
The FlipSwitch focus brush. The default value is
DarkGoldenrod
.
FocusExtent
Gets or sets the extent of the focus indicator. This is a dependency property.
public Unit FocusExtent { get; set; }
Property Value
- Unit:
The extent of the focus indicator. The default value is
3%
.
IsChecked
Gets or sets whether the FlipSwitch is checked. This is a dependency property.
public bool? IsChecked { get; set; }
Property Value
- bool?:
true
if the FlipSwitch is checked;false
if the FlipSwitch is unchecked; otherwisenull
. The default value isfalse
.
IsSwitchEffectEnabled
Gets and sets a value indicating whether a special effect should be rendered for the switch. This is a dependency property.
public bool IsSwitchEffectEnabled { get; set; }
Property Value
- bool:
true
if the switch effect is enabled; otherwise,false
. The default value istrue
.
IsThreeState
Gets or sets whether the control supports two or three states. This is a dependency property.
public bool IsThreeState { get; set; }
Property Value
- bool:
true
if the control supports three states; otherwise,false
. The default value isfalse
.
RenderedFocused
Gets and sets a value indicating whether the switch should be rendered with a focus indicator. This is a dependency property.
protected bool RenderedFocused { get; set; }
Property Value
- bool:
true
if the switch should be rendered with a focus indicator; otherwise,false
. The default value isfalse
.
ShaftBrush
Gets or sets the brush used to render the shaft of the switch. This is a dependency property.
public Brush ShaftBrush { get; set; }
Property Value
- Brush:
The brush used to render the shaft of the switch. The default value is
Gray
.
SwitchInterval
Gets or sets the interval that it takes the switch to travel to a new location. This is a dependency property.
public Duration SwitchInterval { get; set; }
Property Value
- Duration:
The interval that it takes the switch to travel to a new location. The default value is
250
milliseconds.
SwitchOffset
Gets or sets the offset of the switch, which is used to move it up and down. This is a dependency property.
protected double SwitchOffset { get; set; }
Property Value
- double:
The offset of the switch. The default value is
0
.
SwitchRadiusRatio
Gets or sets the radius of the switch as a ratio of the Radius
property.
This is a dependency property.
public double SwitchRadiusRatio { get; set; }
Property Value
- double:
The radius of the switch as a ratio of the
Radius
property. The default value is0.75
.
SwitchType
Gets or sets the type of switch rendered. This is a dependency property.
public FlipSwitchType SwitchType { get; set; }
Property Value
- FlipSwitchType:
The type of switch rendered. The default value is Circular.
TipBrush
Gets or sets the brush used to render the tip of the switch. This is a dependency property.
public Brush TipBrush { get; set; }
Property Value
- Brush:
The brush used to render the tip of the switch. The default value is
Gray
.
Methods
OnChecked(RoutedEventArgs)
Raises the Checked event.
protected virtual void OnChecked(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs instance containing the event data. |
OnCreateAutomationPeer()
Creates an appropriate FlipSwitchAutomationPeer for this control as part of the WPF infrastructure.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer:
An instance of FlipSwitchAutomationPeer.
OnIndeterminate(RoutedEventArgs)
Raises the Indeterminate event.
protected virtual void OnIndeterminate(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs instance containing the event data. |
OnMouseDown(MouseButtonEventArgs)
Invoked when an unhandled Mouse.MouseDown
attached event reaches an element in its route that is derived from this
class. Implement this method to add class handling for this event.
protected override void OnMouseDown(MouseButtonEventArgs e)
Parameter | Type | Description |
---|---|---|
e | MouseButtonEventArgs | The MouseButtonEventArgs that contains the event data. This event data reports details about the mouse button that was pressed and the handled state. |
OnRender(DrawingContext)
When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
protected override void OnRender(DrawingContext drawingContext)
Parameter | Type | Description |
---|---|---|
drawingContext | DrawingContext | The drawing instructions for a specific element. This context is provided to the layout system. |
OnToggle()
Called by the OnClick
method to implement toggle behavior.
OnUnchecked(RoutedEventArgs)
Raises the Unchecked event.
protected virtual void OnUnchecked(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs instance containing the event data. |
RenderFlipSwitch(DrawingContext)
Renders the switch based on various properties.
protected virtual void RenderFlipSwitch(DrawingContext drawingContext)
Parameter | Type | Description |
---|---|---|
drawingContext | DrawingContext | The drawing context. |
UpdateSwitchOffset()
Updates the SwitchOffset, usually with an animation.
protected virtual void UpdateSwitchOffset()
Events
Checked
Occurs when the IsChecked property is changed to true
.
Indeterminate
Occurs when the IsChecked property is changed to null
.
Unchecked
Occurs when the IsChecked property is changed to false
.
Fields
BallBrushProperty
Identifies the BallBrush dependency property. This field is read-only.
public static readonly DependencyProperty BallBrushProperty
BaseAccentBrushProperty
Identifies the BaseAccentBrush dependency property. This field is read-only.
public static readonly DependencyProperty BaseAccentBrushProperty
BaseBackgroundProperty
Identifies the BaseBackground dependency property. This field is read-only.
public static readonly DependencyProperty BaseBackgroundProperty
CheckedEvent
Identifies the Checked routed event. This field is read-only.
public static readonly RoutedEvent CheckedEvent
FocusBrushProperty
Identifies the FocusBrush dependency property. This field is read-only.
public static readonly DependencyProperty FocusBrushProperty
FocusExtentProperty
Identifies the FocusExtent dependency property. This field is read-only.
public static readonly DependencyProperty FocusExtentProperty
IndeterminateEvent
Identifies the Checked routed event. This field is read-only.
public static readonly RoutedEvent IndeterminateEvent
IsCheckedProperty
Identifies the IsChecked dependency property. This field is read-only.
public static readonly DependencyProperty IsCheckedProperty
IsSwitchEffectEnabledProperty
Identifies the IsSwitchEffectEnabled dependency property. This field is read-only.
public static readonly DependencyProperty IsSwitchEffectEnabledProperty
IsThreeStateProperty
Identifies the IsThreeState dependency property. This field is read-only.
public static readonly DependencyProperty IsThreeStateProperty
RenderedFocusedProperty
Identifies the RenderedFocused dependency property. This field is read-only.
protected static readonly DependencyProperty RenderedFocusedProperty
ShaftBrushProperty
Identifies the ShaftBrush dependency property. This field is read-only.
public static readonly DependencyProperty ShaftBrushProperty
SwitchIntervalProperty
Identifies the SwitchInterval dependency property. This field is read-only.
public static readonly DependencyProperty SwitchIntervalProperty
SwitchOffsetProperty
Identifies the SwitchOffset dependency property. This field is read-only.
protected static readonly DependencyProperty SwitchOffsetProperty
SwitchRadiusRatioProperty
Identifies the SwitchRadiusRatio dependency property. This field is read-only.
public static readonly DependencyProperty SwitchRadiusRatioProperty
SwitchTypeProperty
Identifies the SwitchType dependency property. This field is read-only.
public static readonly DependencyProperty SwitchTypeProperty
TipBrushProperty
Identifies the TipBrush dependency property. This field is read-only.
public static readonly DependencyProperty TipBrushProperty
UncheckedEvent
Identifies the Checked routed event. This field is read-only.
public static readonly RoutedEvent UncheckedEvent
Inherited Members
- CircularGaugeBase.BackgroundGeometryProperty
- CircularGaugeBase.BackgroundImageSourceProperty
- CircularGaugeBase.BackgroundRadiusRatioProperty
- CircularGaugeBase.BackgroundTypeProperty
- CircularGaugeBase.FrameTypeProperty
- CircularGaugeBase.GlassTypeProperty
- CircularGaugeBase.RadiusProperty
- CircularGaugeBase.RimGeometryProperty
- CircularGaugeBase.RimImageSourceProperty
- CircularGaugeBase.RimTypeProperty
- CircularGaugeBase.ArrangeOverride(Size)
- CircularGaugeBase.GetRadius(DependencyObject)
- CircularGaugeBase.MeasureOverride(Size)
- CircularGaugeBase.RenderFrameBackground(DrawingContext)
- CircularGaugeBase.RenderFrameRim(DrawingContext)
- CircularGaugeBase.SetRadius(DependencyObject, Unit)
- CircularGaugeBase.UpdateUnitBases()
- CircularGaugeBase.BackgroundGeometry
- CircularGaugeBase.BackgroundImageSource
- CircularGaugeBase.BackgroundRadiusRatio
- CircularGaugeBase.BackgroundType
- CircularGaugeBase.FrameType
- CircularGaugeBase.GlassType
- CircularGaugeBase.LogicalChildren
- CircularGaugeBase.Radius
- CircularGaugeBase.RimGeometry
- CircularGaugeBase.RimImageSource
- CircularGaugeBase.RimType
- GaugeBase.BackgroundProperty
- GaugeBase.IsBackgroundEffectEnabledProperty
- GaugeBase.IsRimEffectEnabledProperty
- GaugeBase.OriginProperty
- GaugeBase.RimBrushProperty
- GaugeBase.UnitBaseXProperty
- GaugeBase.UnitBaseYProperty
- GaugeBase.XProperty
- GaugeBase.YProperty
- GaugeBase.GetLocation(UIElement, Size)
- GaugeBase.GetOrigin(DependencyObject)
- GaugeBase.GetX(DependencyObject)
- GaugeBase.GetY(DependencyObject)
- GaugeBase.OnRenderSizeChanged(SizeChangedInfo)
- GaugeBase.SetOrigin(DependencyObject, CoordinateOrigin)
- GaugeBase.SetX(DependencyObject, Unit)
- GaugeBase.SetY(DependencyObject, Unit)
- GaugeBase.ToBitmap(double, double)
- GaugeBase.Background
- GaugeBase.IsBackgroundEffectEnabled
- GaugeBase.IsRimEffectEnabled
- GaugeBase.Items
- GaugeBase.Origin
- GaugeBase.RimBrush
- GaugeBase.UnitBaseX
- GaugeBase.UnitBaseY
- GaugeBase.X
- GaugeBase.Y
- GaugeElement.ZIndexProperty
- GaugeElement.GetVisualChild(int)
- GaugeElement.GetZIndex(UIElement)
- GaugeElement.SetZIndex(UIElement, int)
- GaugeElement.VisualChildren
- GaugeElement.VisualChildrenCount
- GaugeElement.ZIndex