diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2016-08-16 20:33:44 +0200 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-16 11:33:44 -0700 |
commit | 4226f5b386a83dc9eb2f0c06f4920ac1be19e036 (patch) | |
tree | a1e0e9ac88967d31d52750e4082d29695079f4a8 /Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs | |
parent | 3ca06ea14603abded9c15287865a51a3add4e436 (diff) | |
download | xamarin-forms-4226f5b386a83dc9eb2f0c06f4920ac1be19e036.tar.gz xamarin-forms-4226f5b386a83dc9eb2f0c06f4920ac1be19e036.tar.bz2 xamarin-forms-4226f5b386a83dc9eb2f0c06f4920ac1be19e036.zip |
[Xaml] Clone node tree on DT, allow markup to be evaluated multiple times (#295)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs')
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs new file mode 100644 index 00000000..6f9ef80a --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/TypeExtension.xaml.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Windows.Input; +using Xamarin.Forms; +using NUnit.Framework; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public enum NavigationOperation + { + Forward, + Back, + Replace, + } + + [ContentProperty(nameof(Operation))] + public class NavigateExtension : IMarkupExtension<ICommand> + { + public NavigationOperation Operation { get; set; } + + public Type Type { get; set; } + + public ICommand ProvideValue(IServiceProvider serviceProvider) + { + return new Command(() => { }); + } + + object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) + { + return ProvideValue(serviceProvider); + } + } + + public partial class TypeExtension : ListView + { + public TypeExtension() + { + InitializeComponent(); + } + + public TypeExtension(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + public class Tests + { + [TestCase(false)] + [TestCase(true)] + public void NestedMarkupExtensionInsideDataTemplate(bool useCompiledXaml) + { + var listView = new TypeExtension(useCompiledXaml); + listView.ItemsSource = new string [2]; + + var cell = (ViewCell)listView.TemplatedItems [0]; + var button = (Button)cell.View; + Assert.IsNotNull(button.Command); + + cell = (ViewCell)listView.TemplatedItems [1]; + button = (Button)cell.View; + Assert.IsNotNull(button.Command); + } + } + } +}
\ No newline at end of file |