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

DataTrigger in XAML throwing an error

$
0
0

Howdy folks,

I'm trying to use a DataTrigger to optionally color a label in a listview cell when certain conditions are met. However, I get this error at runtime when navigating to the relevant page:

Xamarin.Forms.Xaml.XamlParseException: Position 26:22. The Property TargetType is required to create a Xamarin.Forms.DataTrigger object.

The XAML fragment causing the issue on the page is:

  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <ViewCell.View>
          <StackLayout Orientation="Horizontal">
            <Label Text="{Binding UserNamePlusContactOrder}" Font="Large">
              <Label.Triggers>
                <DataTrigger TargetType="Label" Binding="{Binding ContactOrder}" Value="Primary" TargetType="Label">
                  <Setter Property="Label.TextColor" Value="Green"/>
                </DataTrigger>
              </Label.Triggers>                  
            </Label>
          </StackLayout>
        </ViewCell.View>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>

As you can see, the TargetType attribute is defined in the XAML for the page. Yet, Xamarin complains that it's missing. What am I doing wrong?


Viewing all articles
Browse latest Browse all 58056

Trending Articles