1
框架背景顏色通過轉換器應用於ios和android。爲Android的 它工作正常。但對於ios不能正常工作。ios中的框架背景顏色xamarin形式不起作用
請找到下面的Xaml代碼。
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Frame Margin="0,5"
Padding="10"
CornerRadius="5"
BackgroundColor="{Binding IsSelected, Converter={StaticResource boolToColor}}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="32" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Title}"
FontSize="Medium"
TextColor="White"
Style="{StaticResource lblSecondaryStyle}" />
<Image Grid.Column="1"
Source="{Binding IsSelected, Converter={StaticResource boolToImage}}"
HeightRequest="30"
WidthRequest="30"
Aspect="AspectFit"
HorizontalOptions="End" />
</Grid>
</Frame>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
下面是我的boolToColorConverter邏輯。
public class BoolToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
{
return value;
}
if (System.Convert.ToBoolean(value))
{
return (Color)Application.Current.Resources["primary"];
}
return (Color)Application.Current.Resources["Secondary_blue_background"];
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
注: - 在我的XAML代碼我也用boolToImageConverter其綁定到相同的屬性IsSelected讓我吃驚它工作正常。
請指導我在哪裏做錯了。
可否請你分享一些相關的代碼,這樣,我們可以看到什麼可能導致的問題。 – Digitalsa1nt
@ Digitalsa1nt - 請找到上面的代碼 – Jayesh92