diff --git a/src/Perspex.Controls/Button.cs b/src/Perspex.Controls/Button.cs
index bb08eff978..d6c44dfffb 100644
--- a/src/Perspex.Controls/Button.cs
+++ b/src/Perspex.Controls/Button.cs
@@ -14,29 +14,60 @@ namespace Perspex.Controls
using Perspex.Rendering;
using Perspex.VisualTree;
+ ///
+ /// Defines how a reacts to clicks.
+ ///
public enum ClickMode
{
+ ///
+ /// The event is raised when the pointer is released.
+ ///
Release,
+
+ ///
+ /// The event is raised when the pointer is pressed.
+ ///
Press,
}
+ ///
+ /// A button control.
+ ///
public class Button : ContentControl
{
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty ClickModeProperty =
- PerspexProperty.Register("ClickMode");
+ PerspexProperty.Register(nameof(ClickMode));
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty CommandProperty =
- PerspexProperty.Register("Command");
+ PerspexProperty.Register(nameof(Command));
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty CommandParameterProperty =
- PerspexProperty.Register("CommandParameter");
+ PerspexProperty.Register(nameof(CommandParameter));
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty IsDefaultProperty =
- PerspexProperty.Register("IsDefault");
+ PerspexProperty.Register(nameof(IsDefault));
+ ///
+ /// Defines the event.
+ ///
public static readonly RoutedEvent ClickEvent =
RoutedEvent.Register("Click", RoutingStrategies.Bubble);
+ ///
+ /// Initializes static members of the class.
+ ///
static Button()
{
FocusableProperty.OverrideDefaultValue(typeof(Button), true);
@@ -45,46 +76,65 @@ namespace Perspex.Controls
IsDefaultProperty.Changed.Subscribe(IsDefaultChanged);
}
+ ///
+ /// Raised when the user clicks the button.
+ ///
public event EventHandler Click
{
add { this.AddHandler(ClickEvent, value); }
remove { this.RemoveHandler(ClickEvent, value); }
}
+ ///
+ /// Gets or sets a value indicating how the should react to clicks.
+ ///
public ClickMode ClickMode
{
get { return this.GetValue(ClickModeProperty); }
set { this.SetValue(ClickModeProperty, value); }
}
+ ///
+ /// Gets or sets an to be invoked when the button is clicked.
+ ///
public ICommand Command
{
get { return this.GetValue(CommandProperty); }
set { this.SetValue(CommandProperty, value); }
}
+ ///
+ /// Gets or sets a parameter to be passed to the .
+ ///
public object CommandParameter
{
get { return this.GetValue(CommandParameterProperty); }
set { this.SetValue(CommandParameterProperty, value); }
}
+ ///
+ /// Gets or sets a value indicating whether the button is the default button for the
+ /// window.
+ ///
public bool IsDefault
{
get { return this.GetValue(IsDefaultProperty); }
set { this.SetValue(IsDefaultProperty, value); }
}
+ ///
protected override Size MeasureOverride(Size availableSize)
{
return base.MeasureOverride(availableSize);
}
+ ///
protected override Size ArrangeOverride(Size finalSize)
{
return base.ArrangeOverride(finalSize);
}
+ ///
protected override void OnAttachedToVisualTree(IRenderRoot root)
{
base.OnAttachedToVisualTree(root);
@@ -100,6 +150,7 @@ namespace Perspex.Controls
}
}
+ ///
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter)
@@ -120,6 +171,7 @@ namespace Perspex.Controls
base.OnKeyDown(e);
}
+ ///
protected override void OnKeyUp(KeyEventArgs e)
{
if (e.Key == Key.Space)
@@ -133,6 +185,7 @@ namespace Perspex.Controls
}
}
+ ///
protected override void OnDetachedFromVisualTree(IRenderRoot oldRoot)
{
base.OnDetachedFromVisualTree(oldRoot);
@@ -148,6 +201,10 @@ namespace Perspex.Controls
}
}
+ ///
+ /// Invokes the event.
+ ///
+ /// The event args.
protected virtual void OnClick(RoutedEventArgs e)
{
if (this.Command != null)
@@ -156,6 +213,7 @@ namespace Perspex.Controls
}
}
+ ///
protected override void OnPointerPressed(PointerPressEventArgs e)
{
base.OnPointerPressed(e);
@@ -170,6 +228,7 @@ namespace Perspex.Controls
}
}
+ ///
protected override void OnPointerReleased(PointerEventArgs e)
{
base.OnPointerReleased(e);
@@ -184,6 +243,10 @@ namespace Perspex.Controls
}
}
+ ///
+ /// Called when the property changes.
+ ///
+ /// The event args.
private static void CommandChanged(PerspexPropertyChangedEventArgs e)
{
var button = e.Sender as Button;
@@ -207,6 +270,10 @@ namespace Perspex.Controls
}
}
+ ///
+ /// Called when the property changes.
+ ///
+ /// The event args.
private static void IsDefaultChanged(PerspexPropertyChangedEventArgs e)
{
var button = e.Sender as Button;
@@ -227,6 +294,11 @@ namespace Perspex.Controls
}
}
+ ///
+ /// Called when the event fires.
+ ///
+ /// The event sender.
+ /// The event args.
private void CanExecuteChanged(object sender, EventArgs e)
{
// HACK: Just set the IsEnabled property for the moment. This needs to be changed to
@@ -234,16 +306,27 @@ namespace Perspex.Controls
this.IsEnabled = this.Command == null || this.Command.CanExecute(this.CommandParameter);
}
+ ///
+ /// Starts listening for the Enter key when the button .
+ ///
+ /// The input root.
private void ListenForDefault(IInputElement root)
{
root.AddHandler(InputElement.KeyDownEvent, this.RootKeyDown);
}
+ ///
+ /// Stops listening for the Enter key when the button is no longer .
+ ///
+ /// The input root.
private void StopListeningForDefault(IInputElement root)
{
root.RemoveHandler(InputElement.KeyDownEvent, this.RootKeyDown);
}
+ ///
+ /// Raises the event.
+ ///
private void RaiseClickEvent()
{
RoutedEventArgs click = new RoutedEventArgs
@@ -254,6 +337,11 @@ namespace Perspex.Controls
this.RaiseEvent(click);
}
+ ///
+ /// Called when a key is pressed on the input root and the button .
+ ///
+ /// The event sender.
+ /// The event args.
private void RootKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter && this.IsVisible && this.IsEnabled)
diff --git a/src/Perspex.Controls/CheckBox.cs b/src/Perspex.Controls/CheckBox.cs
index f4231f3497..3652ee8d21 100644
--- a/src/Perspex.Controls/CheckBox.cs
+++ b/src/Perspex.Controls/CheckBox.cs
@@ -8,6 +8,9 @@ namespace Perspex.Controls
{
using Perspex.Controls.Primitives;
+ ///
+ /// A check box control.
+ ///
public class CheckBox : ToggleButton
{
}
diff --git a/src/Perspex.Controls/Control.cs b/src/Perspex.Controls/Control.cs
index c61fc6d9cb..8a4c9e6f14 100644
--- a/src/Perspex.Controls/Control.cs
+++ b/src/Perspex.Controls/Control.cs
@@ -316,11 +316,23 @@ namespace Perspex.Controls
this.SetValue(ParentProperty, parent);
}
+ ///
+ /// Adds a pseudo-class to be set when a property is true.
+ ///
+ /// The property.
+ /// The pseudo-class.
protected static void PseudoClass(PerspexProperty property, string className)
{
PseudoClass(property, x => x, className);
}
+ ///
+ /// Adds a pseudo-class to be set when a property equals a certain value.
+ ///
+ /// The type of the property.
+ /// The property.
+ /// Returns a boolean value based on the property value.
+ /// The pseudo-class.
protected static void PseudoClass(
PerspexProperty property,
Func selector,
@@ -404,6 +416,10 @@ namespace Perspex.Controls
styler.ApplyStyles(this);
}
+ ///
+ /// Makes the control use a different control's logical children as its own.
+ ///
+ /// The logical children to use.
protected void RedirectLogicalChildren(IPerspexList collection)
{
this.logicalChildren = collection;