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 Calculator
class.
public Calculator()
Properties
AcceptsEscape
Gets or sets whether to accept the Escape
key for clearing the calculator's current entry and value.
public bool AcceptsEscape { get; set; }
Property Value
- bool:
true
if theEscape
key 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
Gets the ICommand that can add to memory.
public ICommand AddToMemoryCommand { get; }
Property Value
BackspaceCommand
Gets the ICommand that can backspace a digit.
public ICommand BackspaceCommand { get; }
Property Value
CalculateCommand
Gets the ICommand that can calculate the result.
public ICommand CalculateCommand { get; }
Property Value
ClearCommand
Gets the ICommand that can clear the current entry and value.
public ICommand ClearCommand { get; }
Property Value
ClearEntryCommand
Gets the ICommand that can clear the current entry.
public ICommand ClearEntryCommand { get; }
Property Value
ClearMemoryCommand
Gets the ICommand that can clear memory.
public ICommand ClearMemoryCommand { get; }
Property Value
DigitButtonStyle
Gets or sets the Style to use for digit buttons.
public Style DigitButtonStyle { get; set; }
Property Value
DisplayFontSize
Gets or sets the display font size.
DisplayText
Gets the text that represents the calculator output.
public string DisplayText { get; }
Property Value
- string:
The text that represents the calculator output. The default value is
"0"
.
HasDisplay
Gets or sets whether the calculator output is displayed.
public bool HasDisplay { get; set; }
Property Value
- bool:
true
if the calculator output is displayed; otherwise,false
. The default value istrue
.
HasMemoryButtons
Gets or sets whether the memory buttons are displayed.
public bool HasMemoryButtons { get; set; }
Property Value
- bool:
true
if the memory buttons are displayed; otherwise,false
. The default value istrue
.
InsertDecimalSeparatorCommand
Gets the ICommand that can insert a decimal separator.
public ICommand InsertDecimalSeparatorCommand { get; }
Property Value
InsertDigitCommand
Gets the ICommand that can insert a digit.
public ICommand InsertDigitCommand { get; }
Property Value
IsOutOfRange
public bool IsOutOfRange { get; }
Property Value
See Also
Maximum
Gets or sets the highest possible value.
MemoryButtonStyle
Gets or sets the Style to use for memory buttons.
public Style MemoryButtonStyle { get; set; }
Property Value
Minimum
Gets or sets the lowest possible value.
OperationButtonStyle
Gets or sets the Style to use for operation buttons.
public Style OperationButtonStyle { get; set; }
Property Value
OperationCommand
Gets the ICommand that can execute an operation.
public ICommand OperationCommand { get; }
Property Value
RecallMemoryCommand
Gets the ICommand that can recall memory.
public ICommand RecallMemoryCommand { get; }
Property Value
SetMemoryCommand
Gets the ICommand that can set memory.
public ICommand SetMemoryCommand { get; }
Property Value
SubtractFromMemoryCommand
Gets the ICommand that can subtract from memory.
public ICommand SubtractFromMemoryCommand { get; }
Property Value
Value
Gets or sets the current calculated value.
public double Value { get; set; }
Property Value
- double:
The current calculated value. The default value is
0.0
.
Methods
OnApplyTemplate()
Invoked whenever application code or internal processes call ApplyTemplate
.
public override void OnApplyTemplate()
OnCreateAutomationPeer()
Returns an AutomationPeer object for this control instance.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer:
An AutomationPeer instance.
OnGotFocus(RoutedEventArgs)
Occurs when the control gains focus.
protected override void OnGotFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs that contains the event data. |
OnKeyDown(KeyEventArgs)
Occurs when a key is pressed.
protected override void OnKeyDown(KeyEventArgs e)
Parameter | Type | Description |
---|---|---|
e | KeyEventArgs | The KeyEventArgs that contains the event data. |
OnLostFocus(RoutedEventArgs)
Occurs when the control loses focus.
protected override void OnLostFocus(RoutedEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RoutedEventArgs | The RoutedEventArgs that contains the event data. |
Events
ValueChanged
Occurs after the Value property value changes.
Fields
AcceptsEscapeProperty
Identifies the AcceptsEscape dependency property. This field is read-only.
public static readonly DependencyProperty AcceptsEscapeProperty
DigitButtonStyleProperty
Identifies the DigitButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty DigitButtonStyleProperty
DisplayFontSizeProperty
Identifies the DisplayFontSize dependency property. This field is read-only.
public static readonly DependencyProperty DisplayFontSizeProperty
DisplayTextProperty
Identifies the DisplayText dependency property. This field is read-only.
public static readonly DependencyProperty DisplayTextProperty
HasDisplayProperty
Identifies the HasDisplay dependency property. This field is read-only.
public static readonly DependencyProperty HasDisplayProperty
HasMemoryButtonsProperty
Identifies the HasMemoryButtons dependency property. This field is read-only.
public static readonly DependencyProperty HasMemoryButtonsProperty
IsOutOfRangeProperty
Identifies the IsOutOfRange dependency property. This field is read-only.
public static readonly DependencyProperty IsOutOfRangeProperty
MaximumProperty
Identifies the Maximum dependency property. This field is read-only.
public static readonly DependencyProperty MaximumProperty
MemoryButtonStyleProperty
Identifies the MemoryButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty MemoryButtonStyleProperty
MinimumProperty
Identifies the Minimum dependency property. This field is read-only.
public static readonly DependencyProperty MinimumProperty
OperationButtonStyleProperty
Identifies the OperationButtonStyle dependency property. This field is read-only.
public static readonly DependencyProperty OperationButtonStyleProperty
ValueProperty
Identifies the Value dependency property. This field is read-only.
public static readonly DependencyProperty ValueProperty