找不到密钥的 StaticResource

StaticResource not found for key

尝试create a "require all" multi trigger within Xamarin时,我在执行时抛出异常。

错误:

Xamarin.Forms.Xaml.XamlParseException: Position 18:25. StaticResource not found for key dataHasBeenEntered

突出显示 RaceTeam.MyPage.xaml.g.cs(最后一行)

中的错误
//  <autogenerated>

namespace RaceTeam {
    using System;
    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;


    public partial class MyPage : global::Xamarin.Forms.ContentPage {

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
        private global::Xamarin.Forms.Entry carWeight;

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
        private global::Xamarin.Forms.Entry carDistro;

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
        private global::Xamarin.Forms.Button calculateButton;

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
        private void InitializeComponent() {
            this.LoadFromXaml(typeof(MyPage)); //this line

MyPage.xaml:

<?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:RaceTeam;assembly=RaceTeam"
x:Class="RaceTeam.MyPage">
    <ResourceDictionary>
       <local:MultiTriggerConverter x:Key="dataHasBeenEntered"/>
    </ResourceDictionary>
    <ContentPage.Padding>
        <OnPlatform x:TypeArguments="Thickness" iOS="20, 40, 20, 20" Android="20, 20, 20, 20" WinPhone="20, 20, 20, 20" />
    </ContentPage.Padding>
    <ContentPage.Content>
        <StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Orientation="Vertical" Spacing="15">
            <Label Text="Car Weight (lbs)" />
            <Entry x:Name="carWeight" Text="" Keyboard="Numeric" Placeholder="1000-9000" />
            <Label Text="Car (Front) Distribution %" />
            <Entry x:Name="carDistro" Text="" Keyboard="Numeric" Placeholder="25-75" />
            <Button x:Name="calculateButton" Text="Calculate" Clicked="onCalculate" IsEnabled="false">
                <MultiTrigger TargetType="Button">
                    <MultiTrigger.Conditions>
                        <BindingCondition Binding="{Binding Source={x:Reference carWeight}, Path=Text.Length, Converter={StaticResource dataHasBeenEntered}}" Value="true"/>
                        <BindingCondition Binding="{Binding Source={x:Reference carDistro}, Path=Text.Length, Converter={StaticResource dataHasBeenEntered}}" Value="true"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="True" />
                </MultiTrigger>
            </Button>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

MyPage.xaml.cs

using System;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Globalization;

namespace RaceTeam
{
    public partial class MyPage : ContentPage
    { //...//
    }

    public class MultiTriggerConverter : IValueConverter
    {
        public object Convert (object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            //...//
        }
        public object ConvertBack (object value, Type targetType,
                                  object parameter, CultureInfo culture)
        {
            throw new NotSupportedException ();
        }
    }
}

我不熟悉 xaml 或 c# 如何处理 类,所以我的故障排除没有解决任何问题。

我缺少一些 xml 类型的资源嵌套结构。这次更新后一切正常。

MyPage.xaml:

<ContentPage ...>
   .
   .
   .
   <ContentPage.Resources>  <!--***Added this part***-->
            <ResourceDictionary>
                ...
            </ResourceDictionary>
   </ContentPage.Resources>
      .
      .
      .
      <Button ...>
         <Button.Triggers>   <!--***Added this part***-->
            <MultiTrigger ...>
                .
                .
                .
            </MultiTrigger>
         </Button.Triggers>
         .
         .
         .