При попытке создать мультитриггер "требовать все" в Xamarin, я выбрасываю исключение при выполнении.
Ошибка:
Xamarin.Forms.Xaml.XamlParseException: позиция 18:25. StaticResource не найден для ключевых данныхHasBeenEntered
Что подчеркивает ошибку в 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
Моя страница.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# обрабатывает классы, поэтому устранение неполадок ничего не исправило.