我正在学习毛伊语,这个装订的东西还是很棘手的.
我有一个这样的XAML:
<ScrollView Grid.Row="1"
Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
HorizontalScrollBarVisibility="Default"
VerticalOptions="Center">
<HorizontalStackLayout RadioButtonGroup.GroupName="MenuCategories"
x:Name="foodTypeStack"
VerticalOptions="Start"
Spacing="3">
<BindableLayout.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding .}">
<RadioButton.ControlTemplate>
<ControlTemplate>
<Grid>
<Border x:Name="dishTypeContainer"
MinimumWidthRequest="80"
MaximumHeightRequest="140"
Padding="8,0,8,0"
Stroke="Transparent">
<Border.StrokeShape>
<RoundRectangle CornerRadius="20,20,20,20" />
</Border.StrokeShape>
<Label x:Name="dishTypeTextLabel"
HorizontalOptions="Center"
Text="{TemplateBinding Content.Name}"
FontFamily="Icons"
VerticalOptions="Center" />
</Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CheckedStates">
<VisualState x:Name="Checked">
<VisualState.Setters>
<Setter TargetName="dishTypeTextLabel"
Property="Label.TextColor"
Value="WhiteSmoke" />
<Setter TargetName="dishTypeContainer"
Property="Border.BackgroundColor"
Value="{StaticResource DarkSeaBlue}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Unchecked">
<VisualState.Setters>
<Setter TargetName="dishTypeTextLabel"
Property="Label.TextColor"
Value="{StaticResource LightGray}" />
<Setter TargetName="dishTypeContainer"
Property="Border.BackgroundColor"
Value="WhiteSmoke" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</RadioButton.ControlTemplate>
</RadioButton>
</DataTemplate>
</BindableLayout.ItemTemplate>
</HorizontalStackLayout>
</ScrollView>
在.cs文件中,我有这种类型的绑定:
protected override async void OnAppearing()
{
base.OnAppearing();
var foodTypes = await menuDatabase.GetFoodTypeListAsync();
BindableLayout.SetItemsSource(foodTypeStack, foodTypes);
}
单选按钮模板上使用的标签的Icons字体是Fontello字体.
问题是,该标签中的字体不适用.在我开始使用绑定表达式之前,它就起作用了.
帖子主题:Re:Колибри
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("Fontello.ttf", "Icons");
fonts.AddFont("Rubik-Light.ttf", "RubikLight");
fonts.AddFont("Rubik-Regular.ttf", "RubikRegular");
});
builder.Services.AddSingleton<MauiAppTestDatabase>();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
这是标签上使用的字符串之一:
 Drink