0
2番目のisvisible
コンバータだけが呼び出される理由は誰にも分かりますか?
シーケンスを変更すると、新しい2番目のコンバータだけが呼び出されます。
コンバータ1はDiaryTypeNahrungsaufnahmeToBoolConverter
、コンバータ2はDiaryTypeAuswirkungToBoolConverter
です。Xamarin Forms/XAML:コンバータが呼び出されていない
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<RelativeLayout IsVisible="{Binding Type, Converter={StaticResource converter1}}"></RelativeLayout>
<RelativeLayout IsVisible="{Binding Type, Converter={StaticResource converter2}}"></RelativeLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
コンバーターコードは次のとおりです。ヘルプ
public class DiaryTypeNahrungsaufnahmeToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
if (value is LibChemotherapie.DiaryType)
{
return ((LibChemotherapie.DiaryType)value) == LibChemotherapie.DiaryType.Food;
}
return false;
}
catch (Exception)
{
return false;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class DiaryTypeAuswirkungToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
if (value is LibChemotherapie.DiaryType)
{
return ((LibChemotherapie.DiaryType)value) == LibChemotherapie.DiaryType.Effect;
}
return false;
}
catch (Exception)
{
return false;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
感謝。
コンバーターのコードは何ですか?質問が今述べられているように、それは広すぎるので、多分答えが多すぎます。詳細を追加してください。そうでなければ、あなたを助けるのが難しいでしょう。 – Demitrian
@Demitrian大丈夫、コンバータを追加しました。コード – Ralf
どこで 'converter1'と' converter2'を定義しましたか?あるいは、あなたの質問のためにあなたのコードにコンバーターの名前を入力するのを避けるために単にそれらの名前を使用しましたか? – Demitrian