diff options
-rw-r--r-- | Xamarin.Forms.Core/Layout.cs | 4 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml | 8 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml.cs | 52 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml | 22 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml.cs | 15 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj | 12 |
6 files changed, 113 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/Layout.cs b/Xamarin.Forms.Core/Layout.cs index 87a3453b..f5b71f3b 100644 --- a/Xamarin.Forms.Core/Layout.cs +++ b/Xamarin.Forms.Core/Layout.cs @@ -70,6 +70,10 @@ namespace Xamarin.Forms protected Layout() { + //if things were added in base ctor (through implicit styles), the items added aren't properly parented + if (InternalChildren.Count > 0) + InternalChildrenOnCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, InternalChildren)); + InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged; } diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml new file mode 100644 index 00000000..a278159c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentView xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Class="Xamarin.Forms.Xaml.UnitTests.Bz53381"> + <Grid BackgroundColor="Green"> + <Label Text="This is my custom control."/> + </Grid> +</ContentView>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml.cs new file mode 100644 index 00000000..95d150ff --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using Xamarin.Forms; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz53381 : ContentView + { + public Bz53381() + { + InitializeComponent(); + } + + public Bz53381(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Application.Current = null; + Device.PlatformServices = null; + } + + [TestCase(true)] + [TestCase(false)] + public void ControlTemplateAsImplicitAppLevelStyles(bool useCompiledXaml) + { + Application.Current = new Bz53381App(); + var view = new Bz53381(useCompiledXaml); + Application.Current.MainPage = new ContentPage { Content = view }; + var presenter = ((StackLayout)view.InternalChildren[0]).Children[1] as ContentPresenter; + Assume.That(presenter, Is.Not.Null); + var grid = presenter.Content as Grid; + Assert.That(grid, Is.Not.Null); + Assert.That(grid.BackgroundColor, Is.EqualTo(Color.Green)); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml new file mode 100644 index 00000000..d25f6b42 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Application 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.Bz53381App"> + <Application.Resources> + <ResourceDictionary> + <Style TargetType="local:Bz53381"> + <Setter Property="ControlTemplate"> + <Setter.Value> + <ControlTemplate> + <StackLayout> + <Label Text="This is the control template. A green Grid and Label should be below." /> + <ContentPresenter /> + </StackLayout> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </ResourceDictionary> + </Application.Resources> +</Application>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml.cs new file mode 100644 index 00000000..b2dbcbbd --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz53381App.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz53381App : Application + { + public Bz53381App() + { + InitializeComponent(); + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index 8cdd821d..e2162091 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -452,6 +452,12 @@ <Compile Include="Issues\Bz53318.xaml.cs"> <DependentUpon>Bz53318.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Bz53381.xaml.cs"> + <DependentUpon>Bz53381.xaml</DependentUpon> + </Compile> + <Compile Include="Issues\Bz53381App.xaml.cs"> + <DependentUpon>Bz53381App.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -824,6 +830,12 @@ <EmbeddedResource Include="Issues\Bz53318.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> + <EmbeddedResource Include="Issues\Bz53381.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> + <EmbeddedResource Include="Issues\Bz53381App.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |