summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-04-17 23:59:44 +0200
committerJason Smith <jason.smith@xamarin.com>2016-04-17 14:59:44 -0700
commitcdd6d4defc844b605890e7ad731e27e373b09bf4 (patch)
treeddf897b6bf475273a247891898a6c7daf7fb2079
parent0b10ab0c130c814b4ab1595c8d13c4c6c9c9d5df (diff)
downloadxamarin-forms-cdd6d4defc844b605890e7ad731e27e373b09bf4.tar.gz
xamarin-forms-cdd6d4defc844b605890e7ad731e27e373b09bf4.tar.bz2
xamarin-forms-cdd6d4defc844b605890e7ad731e27e373b09bf4.zip
Merged ResourceDictionary (#97)
* [X] Support Merged RD * [X] Support RD as xaml roots * [XamlC] I have no idea how that used to work before * [C] Remove debugging statements * fix docs
-rw-r--r--Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs6
-rw-r--r--Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs37
-rw-r--r--Xamarin.Forms.Core/ResourceDictionary.cs29
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml14
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs34
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml11
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs31
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj12
-rw-r--r--Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs4
-rw-r--r--Xamarin.Forms.Xaml/CreateValuesVisitor.cs4
-rw-r--r--Xamarin.Forms.Xaml/FillResourceDictionariesVisitor.cs29
-rw-r--r--Xamarin.Forms.Xaml/HydratationContext.cs6
-rw-r--r--Xamarin.Forms.Xaml/ViewExtensions.cs4
-rw-r--r--Xamarin.Forms.Xaml/XamlLoader.cs4
-rw-r--r--Xamarin.Forms.Xaml/XamlNode.cs16
-rw-r--r--docs/Xamarin.Forms.Core/Xamarin.Forms/ResourceDictionary.xml25
16 files changed, 236 insertions, 30 deletions
diff --git a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
index 5470a3c8..692ef8b5 100644
--- a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
@@ -118,7 +118,7 @@ namespace Xamarin.Forms.Build.Tasks
if (parentVar.VariableType.ImplementsInterface(Module.Import(typeof (IEnumerable))))
{
var elementType = parentVar.VariableType;
- if (elementType.FullName != "Xamarin.Forms.ResourceDictionary")
+ if (elementType.FullName != "Xamarin.Forms.ResourceDictionary" && elementType.Resolve().BaseType.FullName != "Xamarin.Forms.ResourceDictionary")
{
var adderTuple = elementType.GetMethods(md => md.Name == "Add" && md.Parameters.Count == 1, Module).First();
var adderRef = Module.Import(adderTuple.Item1);
@@ -213,7 +213,7 @@ namespace Xamarin.Forms.Build.Tasks
return parentList.CollectionItems.Contains(node);
}
- static string GetContentProperty(TypeReference typeRef)
+ internal static string GetContentProperty(TypeReference typeRef)
{
var typeDef = typeRef.Resolve();
var attributes = typeDef.CustomAttributes;
@@ -461,7 +461,7 @@ namespace Xamarin.Forms.Build.Tasks
context.IL.Emit(OpCodes.Ldloc, parent);
context.IL.Append(vnode.PushConvertedValue(context,
propertyType,
- new ICustomAttributeProvider[] { propertyType.Resolve() },
+ new ICustomAttributeProvider[] { property, propertyType.Resolve() },
valueNode.PushServiceProvider(context), false, true));
context.IL.Emit(OpCodes.Callvirt, propertySetterRef);
diff --git a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
index c054117c..d09c4b00 100644
--- a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
@@ -36,6 +37,33 @@ namespace Xamarin.Forms.Build.Tasks
public void Visit(ValueNode node, INode parentNode)
{
+ XmlName propertyName;
+ if (!SetPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName))
+ {
+ if (!IsCollectionItem(node, parentNode))
+ return;
+ string contentProperty;
+ if (!Context.Variables.ContainsKey((IElementNode)parentNode))
+ return;
+ var parentVar = Context.Variables[(IElementNode)parentNode];
+ if ((contentProperty = SetPropertiesVisitor.GetContentProperty(parentVar.VariableType)) != null)
+ propertyName = new XmlName(((IElementNode)parentNode).NamespaceURI, contentProperty);
+ else
+ return;
+ }
+
+ if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver)?.LookupPrefix(propertyName.NamespaceURI)))
+ return;
+ if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" &&
+ propertyName.LocalName == "Ignorable")
+ {
+ (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(
+ (node.Value as string).Split(','));
+ return;
+ }
+ if (propertyName.LocalName != "MergedWith")
+ return;
+ SetPropertiesVisitor.SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node);
}
public void Visit(MarkupNode node, INode parentNode)
@@ -52,7 +80,8 @@ namespace Xamarin.Forms.Build.Tasks
var parentVar = Context.Variables[(IElementNode)parentNode];
if (parentVar.VariableType.ImplementsInterface(Module.Import(typeof (IEnumerable))))
{
- if (parentVar.VariableType.FullName == "Xamarin.Forms.ResourceDictionary" &&
+ if ((parentVar.VariableType.FullName == "Xamarin.Forms.ResourceDictionary" ||
+ parentVar.VariableType.Resolve().BaseType.FullName == "Xamarin.Forms.ResourceDictionary") &&
!node.Properties.ContainsKey(XmlName.xKey))
{
node.Accept(new SetPropertiesVisitor(Context), parentNode);
@@ -79,7 +108,8 @@ namespace Xamarin.Forms.Build.Tasks
.Resolve()
.Methods.Single(md => md.Name == "Add" && md.Parameters.Count == 1)));
}
- else if (parentVar.VariableType.FullName == "Xamarin.Forms.ResourceDictionary" &&
+ else if ((parentVar.VariableType.FullName == "Xamarin.Forms.ResourceDictionary" ||
+ parentVar.VariableType.Resolve().BaseType.FullName == "Xamarin.Forms.ResourceDictionary") &&
node.Properties.ContainsKey(XmlName.xKey))
{
node.Accept(new SetPropertiesVisitor(Context), parentNode);
@@ -118,7 +148,8 @@ namespace Xamarin.Forms.Build.Tasks
XmlName propertyName;
if (SetPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName) &&
(propertyName.LocalName == "Resources" || propertyName.LocalName.EndsWith(".Resources", StringComparison.Ordinal)) &&
- Context.Variables[node].VariableType.FullName == "Xamarin.Forms.ResourceDictionary")
+ (Context.Variables[node].VariableType.FullName == "Xamarin.Forms.ResourceDictionary" ||
+ Context.Variables[node].VariableType.Resolve().BaseType.FullName == "Xamarin.Forms.ResourceDictionary"))
SetPropertiesVisitor.SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node);
}
diff --git a/Xamarin.Forms.Core/ResourceDictionary.cs b/Xamarin.Forms.Core/ResourceDictionary.cs
index b19773ff..e5e08bc6 100644
--- a/Xamarin.Forms.Core/ResourceDictionary.cs
+++ b/Xamarin.Forms.Core/ResourceDictionary.cs
@@ -2,13 +2,38 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
+using System.Reflection;
+using System.Linq;
namespace Xamarin.Forms
{
- public sealed class ResourceDictionary : IResourceDictionary, IDictionary<string, object>
+ public class ResourceDictionary : IResourceDictionary, IDictionary<string, object>
{
readonly Dictionary<string, object> _innerDictionary = new Dictionary<string, object>();
+ Type _mergedWith;
+ [TypeConverter (typeof(TypeTypeConverter))]
+ public Type MergedWith {
+ get { return _mergedWith; }
+ set {
+ if (_mergedWith == value)
+ return;
+ _mergedWith = value;
+ if (_mergedWith == null)
+ return;
+
+ _mergedInstance = _mergedWith.GetTypeInfo().BaseType.GetTypeInfo().DeclaredMethods.First(mi => mi.Name == "GetInstance").Invoke(null, new object[] {_mergedWith}) as ResourceDictionary;
+ }
+ }
+
+ static ResourceDictionary _instance;
+ static ResourceDictionary GetInstance(Type type)
+ {
+ return _instance ?? (_instance = ((ResourceDictionary)Activator.CreateInstance (type)));
+ }
+
+ ResourceDictionary _mergedInstance;
+
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
{
((ICollection<KeyValuePair<string, object>>)_innerDictionary).Add(item);
@@ -94,7 +119,7 @@ namespace Xamarin.Forms
public bool TryGetValue(string key, out object value)
{
- return _innerDictionary.TryGetValue(key, out value);
+ return _innerDictionary.TryGetValue(key, out value) || (_mergedInstance != null && _mergedInstance.TryGetValue(key, out value));
}
event EventHandler<ResourcesChangedEventArgs> IResourceDictionary.ValuesChanged
diff --git a/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml
new file mode 100644
index 00000000..8d86d57a
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.SharedResourceDictionary">
+ <Style x:Key="sharedfoo" TargetType="Label">
+ <Setter Property="TextColor" Value="Pink" />
+ </Style>
+ <Style x:Key="sharedbar" TargetType="Label">
+ <Setter Property="TextColor" Value="Blue" />
+ </Style>
+ <Style TargetType="Label">
+ <Setter Property="TextColor" Value="Red" />
+ </Style>
+</ResourceDictionary> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs
new file mode 100644
index 00000000..f4f53cae
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+
+using Xamarin.Forms;
+
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class SharedResourceDictionary : ResourceDictionary
+ {
+ public SharedResourceDictionary ()
+ {
+ InitializeComponent ();
+ }
+
+ public SharedResourceDictionary (bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ public class Tests
+ {
+ [TestCase (false)]
+ [TestCase (true)]
+ public void ResourcesDirectoriesCanBeXamlRoots (bool useCompiledXaml)
+ {
+ var layout = new SharedResourceDictionary (useCompiledXaml);
+ Assert.AreEqual (3, layout.Count);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml
new file mode 100644
index 00000000..eb1eb7e4
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.TestSharedResourceDictionary">
+ <ContentPage.Resources>
+ <ResourceDictionary MergedWith="local:SharedResourceDictionary">
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <Label x:Name="label" Style="{StaticResource sharedfoo}"/>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs
new file mode 100644
index 00000000..dff3f893
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class TestSharedResourceDictionary : ContentPage
+ {
+ public TestSharedResourceDictionary ()
+ {
+ InitializeComponent ();
+ }
+
+ public TestSharedResourceDictionary (bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ public class Tests
+ {
+ [TestCase (false)]
+ [TestCase (true)]
+ public void MergedResourcesAreFound (bool useCompiledXaml)
+ {
+ var layout = new TestSharedResourceDictionary (useCompiledXaml);
+ Assert.AreEqual (Color.Pink, layout.label.TextColor);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 961774f0..54433f56 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -335,6 +335,12 @@
<DependentUpon>McIgnorable.xaml</DependentUpon>
</Compile>
<Compile Include="XamlLoaderCreateTests.cs" />
+ <Compile Include="SharedResourceDictionary.xaml.cs">
+ <DependentUpon>SharedResourceDictionary.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="TestSharedResourceDictionary.xaml.cs">
+ <DependentUpon>TestSharedResourceDictionary.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -596,6 +602,12 @@
<EmbeddedResource Include="McIgnorable.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="SharedResourceDictionary.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ <EmbeddedResource Include="TestSharedResourceDictionary.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
diff --git a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
index 8978f4fd..0a0651a7 100644
--- a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
+++ b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
@@ -133,7 +133,7 @@ namespace Xamarin.Forms.Xaml
if (typeof (IEnumerable).GetTypeInfo().IsAssignableFrom(Context.Types[parentElement].GetTypeInfo()))
{
var source = Values[parentNode];
- if (Context.Types[parentElement] != typeof (ResourceDictionary))
+ if (!(typeof (ResourceDictionary).IsAssignableFrom(Context.Types[parentElement])))
{
var addMethod =
Context.Types[parentElement].GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
@@ -291,7 +291,7 @@ namespace Xamarin.Forms.Xaml
return null;
}
- public static void SetPropertyValue(object xamlelement, XmlName propertyName, object value, BindableObject rootElement,
+ public static void SetPropertyValue(object xamlelement, XmlName propertyName, object value, object rootElement,
INode node, HydratationContext context, IXmlLineInfo lineInfo)
{
var elementType = xamlelement.GetType();
diff --git a/Xamarin.Forms.Xaml/CreateValuesVisitor.cs b/Xamarin.Forms.Xaml/CreateValuesVisitor.cs
index d54a36d5..612b32f1 100644
--- a/Xamarin.Forms.Xaml/CreateValuesVisitor.cs
+++ b/Xamarin.Forms.Xaml/CreateValuesVisitor.cs
@@ -149,7 +149,9 @@ namespace Xamarin.Forms.Xaml
var rnode = (XamlLoader.RuntimeRootNode)node;
Values[node] = rnode.Root;
Context.Types[node] = rnode.Root.GetType();
- NameScope.SetNameScope(rnode.Root as BindableObject, node.Namescope);
+ var bindableRoot = rnode.Root as BindableObject;
+ if (bindableRoot != null)
+ NameScope.SetNameScope(bindableRoot, node.Namescope);
}
public void Visit(ListNode node, INode parentNode)
diff --git a/Xamarin.Forms.Xaml/FillResourceDictionariesVisitor.cs b/Xamarin.Forms.Xaml/FillResourceDictionariesVisitor.cs
index 5eb47887..c140084a 100644
--- a/Xamarin.Forms.Xaml/FillResourceDictionariesVisitor.cs
+++ b/Xamarin.Forms.Xaml/FillResourceDictionariesVisitor.cs
@@ -37,6 +37,27 @@ namespace Xamarin.Forms.Xaml
public void Visit(ValueNode node, INode parentNode)
{
+ var parentElement = parentNode as IElementNode;
+ var value = Values [node];
+ var source = Values [parentNode];
+
+ XmlName propertyName;
+ if (ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) {
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+ if (parentElement.SkipPrefix(node.NamespaceResolver.LookupPrefix(propertyName.NamespaceURI)))
+ return;
+ if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" &&
+ propertyName.LocalName == "Ignorable") {
+ (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string> ())).AddRange (
+ (value as string).Split (','));
+ return;
+ }
+ if (propertyName.LocalName != "MergedWith")
+ return;
+ ApplyPropertiesVisitor.SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
+ }
+
}
public void Visit(MarkupNode node, INode parentNode)
@@ -56,10 +77,10 @@ namespace Xamarin.Forms.Xaml
//Set Resources in ResourcesDictionaries
if (IsCollectionItem(node, parentNode) && parentNode is IElementNode)
{
- if (typeof (IEnumerable).GetTypeInfo().IsAssignableFrom(Context.Types[parentElement].GetTypeInfo()))
+ if (typeof (IEnumerable).IsAssignableFrom(Context.Types[parentElement]))
{
var source = Values[parentNode];
- if (Context.Types[parentElement] == typeof (ResourceDictionary) && value is Style &&
+ if (typeof (ResourceDictionary).IsAssignableFrom(Context.Types[parentElement]) && value is Style &&
!node.Properties.ContainsKey(XmlName.xKey))
{
node.Accept(new ApplyPropertiesVisitor(Context), parentNode);
@@ -75,9 +96,9 @@ namespace Xamarin.Forms.Xaml
}
((ResourceDictionary)source).Add(value as Style);
}
- else if (Context.Types[parentElement] == typeof (ResourceDictionary) && !node.Properties.ContainsKey(XmlName.xKey))
+ else if (typeof (ResourceDictionary).IsAssignableFrom(Context.Types[parentElement]) && !node.Properties.ContainsKey(XmlName.xKey))
throw new XamlParseException("resources in ResourceDictionary require a x:Key attribute", node);
- else if (Context.Types[parentElement] == typeof (ResourceDictionary) && node.Properties.ContainsKey(XmlName.xKey))
+ else if (typeof (ResourceDictionary).IsAssignableFrom(Context.Types[parentElement]) && node.Properties.ContainsKey(XmlName.xKey))
{
node.Accept(new ApplyPropertiesVisitor(Context), parentNode);
if (markupExtension != null)
diff --git a/Xamarin.Forms.Xaml/HydratationContext.cs b/Xamarin.Forms.Xaml/HydratationContext.cs
index 7c1356d9..7273a2cc 100644
--- a/Xamarin.Forms.Xaml/HydratationContext.cs
+++ b/Xamarin.Forms.Xaml/HydratationContext.cs
@@ -17,8 +17,8 @@ namespace Xamarin.Forms.Xaml
public HydratationContext ParentContext { get; set; }
- public BindableObject RootElement { get; set; }
-
public bool DoNotThrowOnExceptions { get; set; }
+
+ public object RootElement { get; set; }
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Xaml/ViewExtensions.cs b/Xamarin.Forms.Xaml/ViewExtensions.cs
index fb8a612a..38d5becf 100644
--- a/Xamarin.Forms.Xaml/ViewExtensions.cs
+++ b/Xamarin.Forms.Xaml/ViewExtensions.cs
@@ -31,13 +31,13 @@ namespace Xamarin.Forms.Xaml
{
public static class Extensions
{
- public static TView LoadFromXaml<TView>(this TView view, Type callingType) where TView : BindableObject
+ public static TXaml LoadFromXaml<TXaml>(this TXaml view, Type callingType)
{
XamlLoader.Load(view, callingType);
return view;
}
- internal static TView LoadFromXaml<TView>(this TView view, string xaml) where TView : BindableObject
+ internal static TXaml LoadFromXaml<TXaml>(this TXaml view, string xaml)
{
XamlLoader.Load(view, xaml);
return view;
diff --git a/Xamarin.Forms.Xaml/XamlLoader.cs b/Xamarin.Forms.Xaml/XamlLoader.cs
index 575f2c7d..37bea4e4 100644
--- a/Xamarin.Forms.Xaml/XamlLoader.cs
+++ b/Xamarin.Forms.Xaml/XamlLoader.cs
@@ -39,7 +39,7 @@ namespace Xamarin.Forms.Xaml
{
static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();
- public static void Load(BindableObject view, Type callingType)
+ public static void Load(object view, Type callingType)
{
var xaml = GetXamlForType(callingType);
if (string.IsNullOrEmpty(xaml))
@@ -47,7 +47,7 @@ namespace Xamarin.Forms.Xaml
Load(view, xaml);
}
- public static void Load(BindableObject view, string xaml)
+ public static void Load(object view, string xaml)
{
using (var reader = XmlReader.Create(new StringReader(xaml)))
{
diff --git a/Xamarin.Forms.Xaml/XamlNode.cs b/Xamarin.Forms.Xaml/XamlNode.cs
index aa8e6c82..6d84c67d 100644
--- a/Xamarin.Forms.Xaml/XamlNode.cs
+++ b/Xamarin.Forms.Xaml/XamlNode.cs
@@ -159,7 +159,7 @@ namespace Xamarin.Forms.Xaml
visitor.Visit(this, parentNode);
}
- static bool IsDataTemplate(INode node, INode parentNode)
+ internal static bool IsDataTemplate(INode node, INode parentNode)
{
var parentElement = parentNode as IElementNode;
INode createContent;
@@ -169,7 +169,7 @@ namespace Xamarin.Forms.Xaml
return false;
}
- static bool IsResourceDictionary(INode node, INode parentNode)
+ internal static bool IsResourceDictionary(INode node, INode parentNode)
{
var enode = node as ElementNode;
return enode.XmlType.Name == "ResourceDictionary";
@@ -186,10 +186,14 @@ namespace Xamarin.Forms.Xaml
{
if (!visitor.VisitChildrenFirst)
visitor.Visit(this, parentNode);
- foreach (var node in Properties.Values.ToList())
- node.Accept(visitor, this);
- foreach (var node in CollectionItems)
- node.Accept(visitor, this);
+ if ((!visitor.StopOnDataTemplate || !IsDataTemplate(this, parentNode)) &&
+ (!visitor.StopOnResourceDictionary || !IsResourceDictionary(this, parentNode)))
+ {
+ foreach (var node in Properties.Values.ToList())
+ node.Accept(visitor, this);
+ foreach (var node in CollectionItems)
+ node.Accept(visitor, this);
+ }
if (visitor.VisitChildrenFirst)
visitor.Visit(this, parentNode);
}
diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/ResourceDictionary.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/ResourceDictionary.xml
index 862bf40a..95690874 100644
--- a/docs/Xamarin.Forms.Core/Xamarin.Forms/ResourceDictionary.xml
+++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/ResourceDictionary.xml
@@ -1,6 +1,6 @@
<Type Name="ResourceDictionary" FullName="Xamarin.Forms.ResourceDictionary">
- <TypeSignature Language="C#" Value="public sealed class ResourceDictionary : System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;string,object&gt;&gt;, System.Collections.Generic.IDictionary&lt;string,object&gt;, System.Collections.Generic.IEnumerable&lt;System.Collections.Generic.KeyValuePair&lt;string,object&gt;&gt;" />
- <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ResourceDictionary extends System.Object implements class System.Collections.Generic.ICollection`1&lt;valuetype System.Collections.Generic.KeyValuePair`2&lt;string, object&gt;&gt;, class System.Collections.Generic.IDictionary`2&lt;string, object&gt;, class System.Collections.Generic.IEnumerable`1&lt;valuetype System.Collections.Generic.KeyValuePair`2&lt;string, object&gt;&gt;, class System.Collections.IEnumerable" />
+ <TypeSignature Language="C#" Value="public class ResourceDictionary : System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;string,object&gt;&gt;, System.Collections.Generic.IDictionary&lt;string,object&gt;, System.Collections.Generic.IEnumerable&lt;System.Collections.Generic.KeyValuePair&lt;string,object&gt;&gt;" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ResourceDictionary extends System.Object implements class System.Collections.Generic.ICollection`1&lt;valuetype System.Collections.Generic.KeyValuePair`2&lt;string, object&gt;&gt;, class System.Collections.Generic.IDictionary`2&lt;string, object&gt;, class System.Collections.Generic.IEnumerable`1&lt;valuetype System.Collections.Generic.KeyValuePair`2&lt;string, object&gt;&gt;, class System.Collections.IEnumerable" />
<AssemblyInfo>
<AssemblyName>Xamarin.Forms.Core</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
@@ -243,6 +243,27 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="MergedWith">
+ <MemberSignature Language="C#" Value="public Type MergedWith { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Type MergedWith" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Attributes>
+ <Attribute>
+ <AttributeName>Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.TypeTypeConverter))</AttributeName>
+ </Attribute>
+ </Attributes>
+ <ReturnValue>
+ <ReturnType>System.Type</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Remove">
<MemberSignature Language="C#" Value="public bool Remove (string key);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool Remove(string key) cil managed" />