diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj
index ff3e6df64f..afc456584a 100644
--- a/samples/ControlCatalog/ControlCatalog.csproj
+++ b/samples/ControlCatalog/ControlCatalog.csproj
@@ -60,6 +60,9 @@
MainWindow.paml
+
+ CheckBoxPage.paml
+
BorderPage.paml
@@ -102,6 +105,9 @@
+
+ Designer
+
diff --git a/samples/ControlCatalog/MainWindow.paml b/samples/ControlCatalog/MainWindow.paml
index c692b34fc6..ac900e7516 100644
--- a/samples/ControlCatalog/MainWindow.paml
+++ b/samples/ControlCatalog/MainWindow.paml
@@ -9,6 +9,7 @@
+
\ No newline at end of file
diff --git a/samples/ControlCatalog/Pages/CheckBoxPage.paml b/samples/ControlCatalog/Pages/CheckBoxPage.paml
new file mode 100644
index 0000000000..bb1d991980
--- /dev/null
+++ b/samples/ControlCatalog/Pages/CheckBoxPage.paml
@@ -0,0 +1,15 @@
+
+
+ CheckBox
+ A check box control
+
+
+ Unchecked
+ Checked
+ Disabled
+
+
+
\ No newline at end of file
diff --git a/samples/ControlCatalog/Pages/CheckBoxPage.paml.cs b/samples/ControlCatalog/Pages/CheckBoxPage.paml.cs
new file mode 100644
index 0000000000..38ca6d3c3d
--- /dev/null
+++ b/samples/ControlCatalog/Pages/CheckBoxPage.paml.cs
@@ -0,0 +1,18 @@
+using Perspex.Controls;
+using Perspex.Markup.Xaml;
+
+namespace ControlCatalog.Pages
+{
+ public class CheckBoxPage : UserControl
+ {
+ public CheckBoxPage()
+ {
+ this.InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ PerspexXamlLoader.Load(this);
+ }
+ }
+}
diff --git a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs
index 9ac24a622e..3ae72e138c 100644
--- a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs
+++ b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using ReactiveUI;
+using Perspex.Controls;
namespace XamlTestApplication.ViewModels
{
@@ -59,6 +60,23 @@ namespace XamlTestApplication.ViewModels
CollapseNodesCommand.Subscribe(_ => ExpandNodes(false));
ExpandNodesCommand = ReactiveCommand.Create();
ExpandNodesCommand.Subscribe(_ => ExpandNodes(true));
+
+ OpenFileCommand = ReactiveCommand.Create();
+ OpenFileCommand.Subscribe(_ =>
+ {
+ var ofd = new OpenFileDialog();
+
+ ofd.ShowAsync();
+ });
+
+ OpenFolderCommand = ReactiveCommand.Create();
+ OpenFolderCommand.Subscribe(_ =>
+ {
+ var ofd = new OpenFolderDialog();
+
+ ofd.ShowAsync();
+ });
+
}
public List Items { get; }
@@ -68,6 +86,10 @@ namespace XamlTestApplication.ViewModels
public ReactiveCommand
+
@@ -74,6 +75,14 @@
{B09B78D8-9B26-48B0-9149-D64A2F120F3F}
Perspex.Base
+
+ {d2221c82-4a25-4583-9b43-d791e3f6820c}
+ Perspex.Controls
+
+
+ {62024b2d-53eb-4638-b26b-85eeaa54866e}
+ Perspex.Input
+
{6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B}
Perspex.Interactivity
@@ -86,6 +95,10 @@
{EB582467-6ABB-43A1-B052-E981BA910E3A}
Perspex.SceneGraph
+
+ {f1baa01a-f176-4c6a-b39d-5b40bb1b148f}
+ Perspex.Styling
+
diff --git a/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Negation.cs b/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Negation.cs
index 3581a71563..9dc40ece00 100644
--- a/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Negation.cs
+++ b/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Negation.cs
@@ -81,12 +81,12 @@ namespace Perspex.Markup.UnitTests.Data
}
[Fact]
- public void SetValue_Should_Throw()
+ public void SetValue_Should_Return_False()
{
var data = new { Foo = "foo" };
var target = new ExpressionObserver(data, "!Foo");
- Assert.Throws(() => target.SetValue("bar"));
+ Assert.False(target.SetValue("bar"));
}
}
}
diff --git a/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Property.cs b/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Property.cs
index fe9336ebe6..ebf98a363e 100644
--- a/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Property.cs
+++ b/tests/Perspex.Markup.UnitTests/Data/ExpressionObserverTests_Property.cs
@@ -108,6 +108,34 @@ namespace Perspex.Markup.UnitTests.Data
Assert.Equal(0, data.SubscriptionCount);
}
+ [Fact]
+ public void Should_Trigger_PropertyChanged_On_Null_Or_Empty_String()
+ {
+ var data = new Class1 { Bar = "foo" };
+ var target = new ExpressionObserver(data, "Bar");
+ var result = new List();
+
+ var sub = target.Subscribe(x => result.Add(x));
+
+ Assert.Equal(new[] { "foo" }, result);
+
+ data.Bar = "bar";
+
+ Assert.Equal(new[] { "foo" }, result);
+
+ data.RaisePropertyChanged(string.Empty);
+
+ Assert.Equal(new[] { "foo", "bar" }, result);
+
+ data.RaisePropertyChanged(null);
+
+ Assert.Equal(new[] { "foo", "bar", "bar" }, result);
+
+ sub.Dispose();
+
+ Assert.Equal(0, data.SubscriptionCount);
+ }
+
[Fact]
public void Should_Track_End_Of_Property_Chain_Changing()
{
@@ -324,6 +352,13 @@ namespace Perspex.Markup.UnitTests.Data
}
}
+ private string _bar;
+ public string Bar
+ {
+ get { return _bar; }
+ set { _bar = value; }
+ }
+
public INext Next
{
get { return _next; }
@@ -333,6 +368,11 @@ namespace Perspex.Markup.UnitTests.Data
RaisePropertyChanged(nameof(Next));
}
}
+
+ public void RaisePropertyChanged(string propertyName)
+ {
+ base.RaisePropertyChanged(propertyName);
+ }
}
private class Class2 : NotifyingBase, INext
diff --git a/tests/Perspex.Markup.UnitTests/DefaultValueConverterTests.cs b/tests/Perspex.Markup.UnitTests/DefaultValueConverterTests.cs
index b438d6af1d..55034a3c53 100644
--- a/tests/Perspex.Markup.UnitTests/DefaultValueConverterTests.cs
+++ b/tests/Perspex.Markup.UnitTests/DefaultValueConverterTests.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Globalization;
+using Perspex.Controls;
using Xunit;
namespace Perspex.Markup.UnitTests
@@ -44,6 +45,18 @@ namespace Perspex.Markup.UnitTests
Assert.Equal(TestEnum.Bar, result);
}
+ [Fact]
+ public void Can_Convert_Int_To_Enum()
+ {
+ var result = DefaultValueConverter.Instance.Convert(
+ 1,
+ typeof(TestEnum),
+ null,
+ CultureInfo.InvariantCulture);
+
+ Assert.Equal(TestEnum.Bar, result);
+ }
+
[Fact]
public void Can_Convert_Double_To_String()
{
@@ -57,15 +70,27 @@ namespace Perspex.Markup.UnitTests
}
[Fact]
- public void Can_Convert_Double_To_Int()
+ public void Can_Convert_Enum_To_Int()
{
var result = DefaultValueConverter.Instance.Convert(
- 5.0,
+ TestEnum.Bar,
typeof(int),
null,
CultureInfo.InvariantCulture);
- Assert.Equal(5, result);
+ Assert.Equal(1, result);
+ }
+
+ [Fact]
+ public void Can_Convert_Enum_To_String()
+ {
+ var result = DefaultValueConverter.Instance.Convert(
+ TestEnum.Bar,
+ typeof(string),
+ null,
+ CultureInfo.InvariantCulture);
+
+ Assert.Equal("Bar", result);
}
[Fact]
@@ -80,6 +105,18 @@ namespace Perspex.Markup.UnitTests
Assert.Equal(5.0, result);
}
+ [Fact]
+ public void Cannot_Convert_Between_Different_Enum_Types()
+ {
+ var result = DefaultValueConverter.Instance.Convert(
+ TestEnum.Foo,
+ typeof(Orientation),
+ null,
+ CultureInfo.InvariantCulture);
+
+ Assert.Equal(PerspexProperty.UnsetValue, result);
+ }
+
private enum TestEnum
{
Foo,