[XamlC] fix parent walking in compiledBPConverter when ListNode is involved (#1228)
This commit is contained in:
Родитель
20ef50d1d3
Коммит
57330e279f
|
@ -31,7 +31,7 @@ namespace Xamarin.Forms.Core.XamlC
|
|||
|
||||
var parts = value.Split('.');
|
||||
if (parts.Length == 1) {
|
||||
var parent = node.Parent?.Parent as IElementNode;
|
||||
var parent = node.Parent?.Parent as IElementNode ?? (node.Parent?.Parent as IListNode)?.Parent as IElementNode;
|
||||
if ((node.Parent as ElementNode)?.XmlType.NamespaceUri == XamlParser.XFUri &&
|
||||
((node.Parent as ElementNode)?.XmlType.Name == "Setter" || (node.Parent as ElementNode)?.XmlType.Name == "PropertyCondition")) {
|
||||
if (parent.XmlType.NamespaceUri == XamlParser.XFUri &&
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?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.Bz60203" >
|
||||
<Label x:Name="label">
|
||||
<Label.Triggers>
|
||||
<MultiTrigger TargetType="Label">
|
||||
<MultiTrigger.Conditions>
|
||||
<BindingCondition Binding="{Binding Text}" Value="Foo"/>
|
||||
<PropertyCondition Property="TextColor" Value="Blue" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BackgroundColor" Value="Pink" />
|
||||
</MultiTrigger>
|
||||
</Label.Triggers>
|
||||
</Label>
|
||||
</ContentPage>
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UnitTests;
|
||||
|
||||
namespace Xamarin.Forms.Xaml.UnitTests
|
||||
{
|
||||
public partial class Bz60203 : ContentPage
|
||||
{
|
||||
public Bz60203()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Bz60203(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()
|
||||
{
|
||||
Device.PlatformServices = null;
|
||||
}
|
||||
|
||||
[TestCase(true), TestCase(false)]
|
||||
public void CanCompileMultiTriggersWithDifferentConditions(bool useCompiledXaml)
|
||||
{
|
||||
var layout = new Bz60203(useCompiledXaml);
|
||||
Assert.That(layout.label.BackgroundColor, Is.EqualTo(BackgroundColorProperty.DefaultValue));
|
||||
layout.BindingContext = new { Text = "Foo" };
|
||||
layout.label.TextColor = Color.Blue;
|
||||
Assert.That(layout.label.BackgroundColor, Is.EqualTo(Color.Pink));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -507,6 +507,9 @@
|
|||
<Compile Include="ResourceLoader.xaml.cs" >
|
||||
<DependentUpon>ResourceLoader.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Issues\Bz60203.xaml.cs">
|
||||
<DependentUpon>Bz60203.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
|
||||
|
@ -944,6 +947,9 @@
|
|||
<EmbeddedResource Include="ResourceLoader.xaml" >
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Issues\Bz60203.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче