Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
Tato platforma pro iOS nastavuje výchozí barvu Cell pozadí instancí. Využívá se v XAML nastavením Cell.DefaultBackgroundColor vlastnosti bindable na Color:
<ContentPage ...
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
<StackLayout Margin="20">
<ListView ItemsSource="{Binding GroupedEmployees}"
IsGroupingEnabled="true">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell ios:Cell.DefaultBackgroundColor="Teal">
<Label Margin="10,10"
Text="{Binding Key}"
FontAttributes="Bold" />
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
...
</ListView>
</StackLayout>
</ContentPage>
Alternativně ho můžete využívat z jazyka C# pomocí rozhraní FLUENT API:
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...
var viewCell = new ViewCell { View = ... };
viewCell.On<iOS>().SetDefaultBackgroundColor(Color.Teal);
Metoda ListView.On<iOS> určuje, že se tato platforma bude spouštět pouze v iOSu. Metoda Cell.SetDefaultBackgroundColor v Xamarin.Forms.PlatformConfiguration.iOSSpecific oboru názvů nastaví barvu pozadí buňky na zadanou Color. Kromě toho lze metodu Cell.DefaultBackgroundColor použít k načtení aktuální barvy pozadí buňky.
Výsledkem je, že barvu pozadí v objektu Cell lze nastavit na konkrétní Color:
