Browse Source

Merge branch 'master' into optimize-selectors

pull/58/head
Steven Kirk 12 years ago
parent
commit
df9951c24e
  1. 8
      Perspex.Base/PerspexObject.cs
  2. 10
      Perspex.Controls/TextBlock.cs
  3. 11
      Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs

8
Perspex.Base/PerspexObject.cs

@ -574,6 +574,14 @@ namespace Perspex
PriorityValue v;
IDescription description = source as IDescription;
if (!this.IsRegistered(property))
{
throw new InvalidOperationException(string.Format(
"Property '{0}' not registered on '{1}'",
property.Name,
this.GetType()));
}
if (!this.values.TryGetValue(property, out v))
{
v = this.CreatePriorityValue(property);

10
Perspex.Controls/TextBlock.cs

@ -17,19 +17,19 @@ namespace Perspex.Controls
Border.BackgroundProperty.AddOwner<TextBlock>();
public static readonly PerspexProperty<string> FontFamilyProperty =
PerspexProperty.Register<TextBlock, string>("FontFamily", inherits: true);
PerspexProperty.RegisterAttached<TextBlock, Control, string>("FontFamily", inherits: true);
public static readonly PerspexProperty<double> FontSizeProperty =
PerspexProperty.Register<TextBlock, double>("FontSize", inherits: true);
PerspexProperty.RegisterAttached<TextBlock, Control, double>("FontSize", inherits: true);
public static readonly PerspexProperty<FontStyle> FontStyleProperty =
PerspexProperty.Register<TextBlock, FontStyle>("FontStyle", inherits: true);
PerspexProperty.RegisterAttached<TextBlock, Control, FontStyle>("FontStyle", inherits: true);
public static readonly PerspexProperty<FontWeight> FontWeightProperty =
PerspexProperty.Register<TextBlock, FontWeight>("FontWeight", inherits: true, defaultValue: FontWeight.Normal);
PerspexProperty.RegisterAttached<TextBlock, Control, FontWeight>("FontWeight", inherits: true, defaultValue: FontWeight.Normal);
public static readonly PerspexProperty<Brush> ForegroundProperty =
PerspexProperty.Register<TextBlock, Brush>("Foreground", new SolidColorBrush(0xff000000), inherits: true);
PerspexProperty.RegisterAttached<TextBlock, Control, Brush>("Foreground", new SolidColorBrush(0xff000000), inherits: true);
public static readonly PerspexProperty<string> TextProperty =
PerspexProperty.Register<TextBlock, string>("Text");

11
Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs

@ -355,6 +355,17 @@ namespace Perspex.Base.UnitTests
Assert.Equal("initial", target.GetValue(Class1.FooProperty));
}
[Fact]
public void Bind_Throws_Exception_For_Unregistered_Property()
{
Class1 target = new Class1();
Assert.Throws<InvalidOperationException>(() =>
{
target.Bind(Class2.BarProperty, Observable.Return("foo"));
});
}
[Fact]
public void Bind_Sets_Subsequent_Value()
{

Loading…
Cancel
Save