Calculator Class
Represents a calculator control.
[TemplateVisualState(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualState(Name = "PointerFocused", GroupName = "FocusStates")]
[TemplateVisualState(Name = "Unfocused", GroupName = "FocusStates")]
public class Calculator : Control
- Inheritance:
- object Visual UIElement FrameworkElement Control object
Constructors
Calculator()
Initializes an instance of the class.
public Calculator()
Properties
AcceptsEscape
Indicates whether to accept the Escape key for clearing the calculator's current entry and value.
public bool AcceptsEscape { get; set; }
Property Value
- bool:
trueif theEscapekey should be accepted; otherwise,false. The default value istrue.
Remarks
The Shift+Del key can also be used to clear the calculator's current entry and value.
AddToMemoryCommand
The ICommand that can add to memory.
BackspaceCommand
The ICommand that can backspace a digit.
CalculateCommand
The ICommand that can calculate the result.
ClearCommand
The ICommand that can clear the current entry and value.
ClearEntryCommand
The ICommand that can clear the current entry.
ClearMemoryCommand
The ICommand that can clear memory.
DigitButtonStyle
The Style to use for digit buttons.
DisplayFontSize
The display font size.
DisplayText
The text that represents the calculator output.
HasDisplay
Indicates whether the calculator output is displayed.
public bool HasDisplay { get; set; }
Property Value
- bool:
trueif the calculator output is displayed; otherwise,false. The default value istrue.
HasMemoryButtons
Indicates whether the memory buttons are displayed.
public bool HasMemoryButtons { get; set; }
Property Value
- bool:
trueif the memory buttons are displayed; otherwise,false. The default value istrue.
InsertDecimalSeparatorCommand
The ICommand that can insert a decimal separator.
InsertDigitCommand
The ICommand that can insert a digit.
IsOutOfRange
public bool IsOutOfRange { get; }
Property Value
See Also
Maximum
The highest possible value.
MemoryButtonStyle
The Style to use for memory buttons.
Minimum
The lowest possible value.
OperationButtonStyle
The Style to use for operation buttons.
OperationCommand
The ICommand that can execute an operation.
RecallMemoryCommand
The ICommand that can recall memory.
SetMemoryCommand
The ICommand that can set memory.
SubtractFromMemoryCommand
The ICommand that can subtract from memory.
Value
The current calculated value.
Methods
OnApplyTemplate()
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().
public override void OnApplyTemplate()
OnCreateAutomationPeer()
Returns class-specific AutomationPeer implementations for the Windows Presentation Foundation (WPF) infrastructure.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer:
The type-specific AutomationPeer implementation.
OnGotFocus(RoutedEventArgs)
Invoked whenever an unhandled GotFocus event reaches this element in its route.
protected override void OnGotFocus(RoutedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | RoutedEventArgs | The RoutedEventArgs that contains the event data. |
OnKeyDown(KeyEventArgs)
Invoked when an unhandled System.Windows.Input.Keyboard.KeyDown 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 OnKeyDown(KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | KeyEventArgs | The KeyEventArgs that contains the event data. |
OnLostFocus(RoutedEventArgs)
Raises the LostFocus routed event by using the event data that is provided.
protected override void OnLostFocus(RoutedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | RoutedEventArgs | A RoutedEventArgs that contains event data. This event data must contain the identifier for the LostFocus event. |
Events
ValueChanged
Occurs after the Value property value changes.
Fields
AcceptsEscapeProperty
Defines the AcceptsEscape property.
public static readonly DependencyProperty AcceptsEscapeProperty
DigitButtonStyleProperty
Defines the DigitButtonStyle property.
public static readonly DependencyProperty DigitButtonStyleProperty
DisplayFontSizeProperty
Defines the DisplayFontSize property.
public static readonly DependencyProperty DisplayFontSizeProperty
DisplayTextProperty
Defines the DisplayText property.
public static readonly DependencyProperty DisplayTextProperty
HasDisplayProperty
Defines the HasDisplay property.
public static readonly DependencyProperty HasDisplayProperty
HasMemoryButtonsProperty
Defines the HasMemoryButtons property.
public static readonly DependencyProperty HasMemoryButtonsProperty
IsOutOfRangeProperty
Defines the IsOutOfRange property.
public static readonly DependencyProperty IsOutOfRangeProperty
MaximumProperty
Defines the Maximum property.
public static readonly DependencyProperty MaximumProperty
MemoryButtonStyleProperty
Defines the MemoryButtonStyle property.
public static readonly DependencyProperty MemoryButtonStyleProperty
MinimumProperty
Defines the Minimum property.
public static readonly DependencyProperty MinimumProperty
OperationButtonStyleProperty
Defines the OperationButtonStyle property.
public static readonly DependencyProperty OperationButtonStyleProperty
ValueProperty
Defines the Value property.
public static readonly DependencyProperty ValueProperty