Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

(Multi-)Triggers: Conditions

$
0
0

Xamarin.Forms: 1.3.1.6296 and 1.3.2.6299-pre

Hi,

I'm just playing around with the Xaml styles and hit an exception (but maybe I'm doing something wrong here):

The following markup throws a XamlParseException: "Can't resolve Text"

<Style x:Key="ButtonStyle" TargetType="Button">
     <Style.Triggers>
          <MultiTrigger TargetType="Button">
               <MultiTrigger.Conditions>
                    <PropertyCondition Property="Text" Value="Matching Text"></PropertyCondition>
               </MultiTrigger.Conditions>
               <MultiTrigger.Setters>
                    <Setter Property="BackgroundColor" Value="Red"/>
               </MultiTrigger.Setters>
          </MultiTrigger>
     </Style.Triggers>
</Style>

also

<Style x:Key="ButtonStyle" TargetType="Button">
     <Style.Triggers>
          <Trigger TargetType="Button">
               <Trigger.Conditions>
                    <PropertyCondition Property="Text" Value="Matching Text"></PropertyCondition>
               </Trigger.Conditions>
               <Trigger.Setters>
                    <Setter Property="BackgroundColor" Value="Red"/>
               </Trigger.Setters>
          </Trigger>
     </Style.Triggers>
</Style>

Exception from MultiTrigger:

Xamarin.Forms.Xaml.XamlParseException: Position 19:39. Can't resolve Text
  at at Xamarin.Forms.BindablePropertyConverter.ConvertFrom (System.Globalization.CultureInfo,object,System.IServiceProvider) <IL 0x000a3, 0x006fc>
  at at Xamarin.Forms.Xaml.TypeConversionExtensions.ConvertTo (object,System.Type,System.Func``1<Xamarin.Forms.TypeConverter>,System.IServiceProvider) <IL 0x00035, 0x00257>
  at at Xamarin.Forms.Xaml.TypeConversionExtensions.ConvertTo (object,System.Type,System.Func``1<System.Reflection.MemberInfo>,System.IServiceProvider) <IL 0x0002a, 0x0017b>
  at at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (object,Xamarin.Forms.Xaml.XmlName,object,Xamarin.Forms.BindableObject,Xamarin.Forms.Xaml.INode,Xamarin.Forms.Xaml.HydratationContext,System.Xml.IXmlLineInfo) <IL 0x003c5, 0x01a8b>
  at at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ValueNode,Xamarin.Forms.Xaml.INode) <IL 0x00051, 0x003fb>
  at at Xamarin.Forms.Xaml.ValueNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x00003, 0x00063>
  at at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x0002e, 0x0025b>
  at at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x0002e, 0x0025b>
  at at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x0002e, 0x0025b>
  at at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x00065, 0x0044b>
  at at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor,Xamarin.Forms.Xaml.INode) <IL 0x0002e, 0x0025b>
  at at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject,string) <IL 0x000bf, 0x00543>
  at at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject,System.Type) <IL 0x0002d, 0x00153>
  at at ...

What's working though is:

<Style x:Key="ButtonStyle" TargetType="Button">
     <Style.Triggers>
          <Trigger TargetType="Button" Property="Text" Value="Matching Text">
               <Trigger.Setters>
                    <Setter Property="BackgroundColor" Value="Red"/>
               </Trigger.Setters>
          </Trigger>
     </Style.Triggers>
</Style>

Is it my fault or a bug?


Viewing all articles
Browse latest Browse all 89864

Trending Articles