diff --git a/Perspex.Base/IObservablePropertyBag.cs b/Perspex.Base/IObservablePropertyBag.cs
new file mode 100644
index 0000000000..868f78ba8d
--- /dev/null
+++ b/Perspex.Base/IObservablePropertyBag.cs
@@ -0,0 +1,37 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2015 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex
+{
+ using System;
+
+ ///
+ /// Interface for getting/setting bindings on an object.
+ ///
+ public interface IObservablePropertyBag : IPropertyBag
+ {
+ ///
+ /// Binds a to an observable.
+ ///
+ /// The property.
+ /// The observable.
+ /// The priority of the binding.
+ ///
+ /// A disposable which can be used to terminate the binding.
+ ///
+ IDisposable Bind(
+ PerspexProperty property,
+ IObservable source,
+ BindingPriority priority = BindingPriority.LocalValue);
+
+ ///
+ /// Gets an observable for a .
+ ///
+ /// The property.
+ /// An observable.
+ IObservable GetObservable(PerspexProperty property);
+ }
+}
\ No newline at end of file
diff --git a/Perspex.Base/IPropertyBag.cs b/Perspex.Base/IPropertyBag.cs
new file mode 100644
index 0000000000..131a0800e9
--- /dev/null
+++ b/Perspex.Base/IPropertyBag.cs
@@ -0,0 +1,49 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2015 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex
+{
+ ///
+ /// Interface for getting/setting values on an object.
+ ///
+ public interface IPropertyBag
+ {
+ ///
+ /// Clears a 's local value.
+ ///
+ /// The property.
+ void ClearValue(PerspexProperty property);
+
+ ///
+ /// Gets a value.
+ ///
+ /// The property.
+ /// The value.
+ object GetValue(PerspexProperty property);
+
+ ///
+ /// Checks whether a is registered on this object.
+ ///
+ /// The property.
+ /// True if the property is registered, otherwise false.
+ bool IsRegistered(PerspexProperty property);
+
+ ///
+ /// Checks whether a is set on this object.
+ ///
+ /// The property.
+ /// True if the property is set, otherwise false.
+ bool IsSet(PerspexProperty property);
+
+ ///
+ /// Sets a value.
+ ///
+ /// The property.
+ /// The value.
+ /// The priority of the value.
+ void SetValue(PerspexProperty property, object value, BindingPriority priority = BindingPriority.LocalValue);
+ }
+}
\ No newline at end of file
diff --git a/Perspex.Base/Perspex.Base.csproj b/Perspex.Base/Perspex.Base.csproj
index 08764a3fe7..d2d9e36101 100644
--- a/Perspex.Base/Perspex.Base.csproj
+++ b/Perspex.Base/Perspex.Base.csproj
@@ -39,6 +39,8 @@
+
+
diff --git a/Perspex.Base/PerspexObject.cs b/Perspex.Base/PerspexObject.cs
index db61e03932..a7ca6b90b5 100644
--- a/Perspex.Base/PerspexObject.cs
+++ b/Perspex.Base/PerspexObject.cs
@@ -66,7 +66,7 @@ namespace Perspex
///
/// This class is analogous to DependencyObject in WPF.
///
- public class PerspexObject : INotifyPropertyChanged
+ public class PerspexObject : IObservablePropertyBag, INotifyPropertyChanged
{
///
/// The registered properties by type.
diff --git a/Perspex.Controls/Controls.cs b/Perspex.Controls/Controls.cs
index 353ecf03db..3515581dea 100644
--- a/Perspex.Controls/Controls.cs
+++ b/Perspex.Controls/Controls.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -9,13 +9,23 @@ namespace Perspex.Controls
using System.Collections.Generic;
using Perspex.Collections;
- public class Controls : PerspexList
+ ///
+ /// A collection of s.
+ ///
+ public class Controls : PerspexList
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
public Controls()
{
}
- public Controls(IEnumerable items)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The initial items in the collection.
+ public Controls(IEnumerable items)
: base(items)
{
}
diff --git a/Perspex.Controls/INavigablePanel.cs b/Perspex.Controls/INavigablePanel.cs
index e35af5e077..23730e2e1c 100644
--- a/Perspex.Controls/INavigablePanel.cs
+++ b/Perspex.Controls/INavigablePanel.cs
@@ -8,8 +8,17 @@ namespace Perspex.Controls
{
using Perspex.Input;
+ ///
+ /// Defines a panel in which the child controls can be navigated by keyboard.
+ ///
public interface INavigablePanel
{
- Control GetControl(FocusNavigationDirection direction, Control from);
+ ///
+ /// Gets the next control in the specified direction.
+ ///
+ /// The movement direction.
+ /// The control from which movement begins.
+ /// The control.
+ IControl GetControl(FocusNavigationDirection direction, IControl from);
}
}
diff --git a/Perspex.Controls/Panel.cs b/Perspex.Controls/Panel.cs
index 26d8825ec4..1ca094f296 100644
--- a/Perspex.Controls/Panel.cs
+++ b/Perspex.Controls/Panel.cs
@@ -118,7 +118,7 @@ namespace Perspex.Controls
/// Clears for the specified controls.
///
/// The controls.
- private void ClearLogicalParent(IEnumerable controls)
+ private void ClearLogicalParent(IEnumerable controls)
{
foreach (var control in controls)
{
@@ -130,7 +130,7 @@ namespace Perspex.Controls
/// Sets for the specified controls.
///
/// The controls.
- private void SetLogicalParent(IEnumerable controls)
+ private void SetLogicalParent(IEnumerable controls)
{
var parent = this.childLogicalParent as Control;
diff --git a/Perspex.Controls/Primitives/AdornerLayer.cs b/Perspex.Controls/Primitives/AdornerLayer.cs
index 7009c580e6..db61dae0c5 100644
--- a/Perspex.Controls/Primitives/AdornerLayer.cs
+++ b/Perspex.Controls/Primitives/AdornerLayer.cs
@@ -52,7 +52,7 @@ namespace Perspex.Controls.Primitives
foreach (var child in this.Children)
{
- var info = child.GetValue(AdornedElementInfoProperty);
+ var info = (AdornedElementInfo)child.GetValue(AdornedElementInfoProperty);
if (info != null)
{
diff --git a/Perspex.Controls/Primitives/SelectingItemsControl.cs b/Perspex.Controls/Primitives/SelectingItemsControl.cs
index 99bfce60e7..26100da8f2 100644
--- a/Perspex.Controls/Primitives/SelectingItemsControl.cs
+++ b/Perspex.Controls/Primitives/SelectingItemsControl.cs
@@ -162,7 +162,7 @@ namespace Perspex.Controls.Primitives
if (next != null)
{
- this.SelectedItem = this.ItemContainerGenerator.GetItemForContainer(next);
+ this.SelectedItem = this.ItemContainerGenerator.GetItemForContainer((Control)next);
}
}
else
diff --git a/Perspex.Controls/StackPanel.cs b/Perspex.Controls/StackPanel.cs
index 123ed22b79..4e3bc8b000 100644
--- a/Perspex.Controls/StackPanel.cs
+++ b/Perspex.Controls/StackPanel.cs
@@ -75,7 +75,7 @@ namespace Perspex.Controls
/// The movement direction.
/// The control from which movement begins.
/// The control.
- Control INavigablePanel.GetControl(FocusNavigationDirection direction, Control from)
+ IControl INavigablePanel.GetControl(FocusNavigationDirection direction, IControl from)
{
var horiz = this.Orientation == Orientation.Horizontal;
int index = this.Children.IndexOf(from);
diff --git a/Perspex.SceneGraph/Visual.cs b/Perspex.SceneGraph/Visual.cs
index a3cfb0024c..142a781b8e 100644
--- a/Perspex.SceneGraph/Visual.cs
+++ b/Perspex.SceneGraph/Visual.cs
@@ -271,7 +271,7 @@ namespace Perspex
/// Adds a visual child to the control.
///
/// The child to add.
- protected void AddVisualChild(Visual visual)
+ protected void AddVisualChild(IVisual visual)
{
Contract.Requires(visual != null);
@@ -282,7 +282,7 @@ namespace Perspex
/// Adds visual children to the control.
///
/// The children to add.
- protected void AddVisualChildren(IEnumerable visuals)
+ protected void AddVisualChildren(IEnumerable visuals)
{
Contract.Requires(visuals != null);
@@ -301,7 +301,7 @@ namespace Perspex
/// Removes a visual child from the control;
///
/// The child to remove.
- protected void RemoveVisualChild(Visual visual)
+ protected void RemoveVisualChild(IVisual visual)
{
Contract.Requires(visual != null);
@@ -312,7 +312,7 @@ namespace Perspex
/// Removes a visual children from the control;
///
/// The children to remove.
- protected void RemoveVisualChildren(IEnumerable visuals)
+ protected void RemoveVisualChildren(IEnumerable visuals)
{
Contract.Requires(visuals != null);
diff --git a/Perspex.Styling/GlobalSuppressions.cs b/Perspex.Styling/GlobalSuppressions.cs
new file mode 100644
index 0000000000..3d080850f1
--- /dev/null
+++ b/Perspex.Styling/GlobalSuppressions.cs
@@ -0,0 +1,14 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2015 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
+ "StyleCop.CSharp.MaintainabilityRules",
+ "SA1401:Fields must be private",
+ Justification = "PerspexProperty fields should not be private.")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
+ "StyleCop.CSharp.DocumentationRules",
+ "SA1609:Property documentation must have value",
+ Justification = "This rule is fscking pointless")]
\ No newline at end of file
diff --git a/Perspex.Styling/Perspex.Styling.csproj b/Perspex.Styling/Perspex.Styling.csproj
index 0773310575..b1e7937084 100644
--- a/Perspex.Styling/Perspex.Styling.csproj
+++ b/Perspex.Styling/Perspex.Styling.csproj
@@ -36,6 +36,7 @@
4
+
diff --git a/Perspex.Styling/Styling/IStyleable.cs b/Perspex.Styling/Styling/IStyleable.cs
index a73b2b5958..007b4cbd3e 100644
--- a/Perspex.Styling/Styling/IStyleable.cs
+++ b/Perspex.Styling/Styling/IStyleable.cs
@@ -11,7 +11,7 @@ namespace Perspex.Styling
///
/// Interface for styleable elements.
///
- public interface IStyleable
+ public interface IStyleable : IObservablePropertyBag
{
///
/// Gets the list of classes for the control.
@@ -32,39 +32,5 @@ namespace Perspex.Styling
/// Gets the template parent of this element if the control comes from a template.
///
ITemplatedControl TemplatedParent { get; }
-
- ///
- /// Binds a to an observable.
- ///
- /// The type of the property.
- /// The property.
- /// The observable.
- /// The priority of the binding.
- ///
- /// A disposable which can be used to terminate the binding.
- ///
- IDisposable Bind(PerspexProperty property, IObservable source, BindingPriority priority);
-
- ///
- /// Gets an observable for a .
- ///
- /// The property.
- /// An observable.
- IObservable GetObservable(PerspexProperty property);
-
- ///
- /// Checks whether a is registered on this class.
- ///
- /// The property.
- /// True if the property is registered, otherwise false.
- bool IsRegistered(PerspexProperty property);
-
- ///
- /// Sets a value.
- ///
- /// The property.
- /// The value.
- /// The priority of the value.
- void SetValue(PerspexProperty property, object value, BindingPriority priority);
}
}
diff --git a/Tests/Perspex.Styling.UnitTests/SelectorTests_Child.cs b/Tests/Perspex.Styling.UnitTests/SelectorTests_Child.cs
index 5ad50a76d6..9fc071a828 100644
--- a/Tests/Perspex.Styling.UnitTests/SelectorTests_Child.cs
+++ b/Tests/Perspex.Styling.UnitTests/SelectorTests_Child.cs
@@ -79,10 +79,15 @@ namespace Perspex.Styling.UnitTests
}
public Classes Classes { get; }
+
public string Name { get; set; }
+
public IPerspexReadOnlyList LogicalChildren { get; set; }
+
public ILogical LogicalParent { get; set; }
+
public Type StyleKey { get; }
+
public ITemplatedControl TemplatedParent { get; }
public IDisposable Bind(PerspexProperty property, IObservable source, BindingPriority priority)
@@ -104,6 +109,21 @@ namespace Perspex.Styling.UnitTests
{
throw new NotImplementedException();
}
+
+ public void ClearValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object GetValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsSet(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
}
public class TestLogical1 : TestLogical
diff --git a/Tests/Perspex.Styling.UnitTests/SelectorTests_Descendent.cs b/Tests/Perspex.Styling.UnitTests/SelectorTests_Descendent.cs
index bde27edcfe..5de13f4aef 100644
--- a/Tests/Perspex.Styling.UnitTests/SelectorTests_Descendent.cs
+++ b/Tests/Perspex.Styling.UnitTests/SelectorTests_Descendent.cs
@@ -111,10 +111,15 @@ namespace Perspex.Styling.UnitTests
}
public Classes Classes { get; }
+
public string Name { get; set; }
+
public IPerspexReadOnlyList LogicalChildren { get; set; }
+
public ILogical LogicalParent { get; set; }
+
public Type StyleKey { get; }
+
public ITemplatedControl TemplatedParent { get; }
public IDisposable Bind(PerspexProperty property, IObservable source, BindingPriority priority)
@@ -136,6 +141,21 @@ namespace Perspex.Styling.UnitTests
{
throw new NotImplementedException();
}
+
+ public void ClearValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object GetValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsSet(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
}
public class TestLogical1 : TestLogical
diff --git a/Tests/Perspex.Styling.UnitTests/TestControlBase.cs b/Tests/Perspex.Styling.UnitTests/TestControlBase.cs
index f58526d8e5..f71e1ef5bc 100644
--- a/Tests/Perspex.Styling.UnitTests/TestControlBase.cs
+++ b/Tests/Perspex.Styling.UnitTests/TestControlBase.cs
@@ -53,5 +53,20 @@ namespace Perspex.Styling.UnitTests
{
throw new NotImplementedException();
}
+
+ public void ClearValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object GetValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsSet(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/Tests/Perspex.Styling.UnitTests/TestTemplatedControl.cs b/Tests/Perspex.Styling.UnitTests/TestTemplatedControl.cs
index 117b60cbab..fcd5d9df6a 100644
--- a/Tests/Perspex.Styling.UnitTests/TestTemplatedControl.cs
+++ b/Tests/Perspex.Styling.UnitTests/TestTemplatedControl.cs
@@ -61,5 +61,20 @@ namespace Perspex.Styling.UnitTests
{
throw new NotImplementedException();
}
+
+ public void ClearValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object GetValue(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsSet(PerspexProperty property)
+ {
+ throw new NotImplementedException();
+ }
}
}