Browse Source

Added IControl interface.

pull/63/head
Steven Kirk 11 years ago
parent
commit
05ec12e2cf
  1. 8
      Perspex.Controls/Control.cs
  2. 33
      Perspex.Controls/IControl.cs
  3. 1
      Perspex.Controls/Perspex.Controls.csproj
  4. 2
      Perspex.Controls/PopupRoot.cs

8
Perspex.Controls/Control.cs

@ -29,7 +29,7 @@ namespace Perspex.Controls
/// - Implements <see cref="IStyleable"/> to allow styling to work on the control.
/// - Implements <see cref="ILogical"/> to form part of a logical tree.
/// </remarks>
public class Control : InputElement, INamed, ILogical, IStyleable, IStyleHost
public class Control : InputElement, IControl
{
/// <summary>
/// Defines the <see cref="DataContext"/> property.
@ -46,8 +46,8 @@ namespace Perspex.Controls
/// <summary>
/// Defines the <see cref="Parent"/> property.
/// </summary>
public static readonly PerspexProperty<Control> ParentProperty =
PerspexProperty.Register<Control, Control>(nameof(Parent));
public static readonly PerspexProperty<IControl> ParentProperty =
PerspexProperty.Register<Control, IControl>(nameof(Parent));
/// <summary>
/// Defines the <see cref="Tag"/> property.
@ -228,7 +228,7 @@ namespace Perspex.Controls
/// <summary>
/// Gets the control's logical parent.
/// </summary>
public Control Parent
public IControl Parent
{
get { return this.GetValue(ParentProperty); }
internal set { this.SetValue(ParentProperty, value); }

33
Perspex.Controls/IControl.cs

@ -0,0 +1,33 @@
// -----------------------------------------------------------------------
// <copyright file="IControl.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Controls
{
using Perspex.Input;
using Perspex.Layout;
using Perspex.Styling;
/// <summary>
/// Interface for Perspex controls.
/// </summary>
public interface IControl : IVisual, ILogical, ILayoutable, IInputElement, INamed, IStyleable, IStyleHost
{
/// <summary>
/// Gets or sets the control's data context.
/// </summary>
object DataContext { get; set; }
/// <summary>
/// Gets the data templates for the control.
/// </summary>
DataTemplates DataTemplates { get; }
/// <summary>
/// Gets the control's logical parent.
/// </summary>
IControl Parent { get; }
}
}

1
Perspex.Controls/Perspex.Controls.csproj

@ -36,6 +36,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="IControl.cs" />
<Compile Include="MenuItemAccessKeyHandler.cs" />
<Compile Include="Parsers\GridLengthsParser.cs" />
<Compile Include="Primitives\AccessText.cs" />

2
Perspex.Controls/PopupRoot.cs

@ -43,7 +43,7 @@ namespace Perspex.Controls
public PopupRoot(IDependencyResolver dependencyResolver)
: base(Locator.Current.GetService<IPopupImpl>(), dependencyResolver)
{
this.GetObservable(ParentProperty).Subscribe(x => this.InheritanceParent = x);
this.GetObservable(ParentProperty).Subscribe(x => this.InheritanceParent = (PerspexObject)x);
}
/// <summary>

Loading…
Cancel
Save