如何更改 Xamarin 中的章节标题字体样式?

2024-04-11

我有这个列表视图,但我不知道如何设置部分标题的样式。在 Xamarin 中如何实现?还没有找到任何东西

<ListView x:Name ="listView" 
            IsGroupingEnabled="true" 
            GroupDisplayBinding="{Binding sectionHeader}"
            HasUnevenRows="true">

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout Orientation="Horizontal" Padding="10">
                        <StackLayout Orientation="Vertical">
                            <Label Text="{Binding Title1}"  FontSize="12" FontAttributes="Bold"/>             
                            <Label Text="{Binding Title2}" FontSize="12" FontAttributes="Bold"/>
                            <Label Text="{Binding SubTitle}" FontSize="12"/>
                        </StackLayout>
                        <Image Source="new_feedback_0.png" HorizontalOptions="EndAndExpand"/>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

您将需要使用ListView.GroupHeaderTemplate with a ViewCell in the DataTemplate. E.g:

<ListView x:Name ="listView" 
      IsGroupingEnabled="true" 
      <!--GroupDisplayBinding="{Binding sectionHeader}" Not Needed anymore since you are providing your own GroupHeaderTemplate for the group header view--> 
      HasUnevenRows="true">
      <ListView.GroupHeaderTemplate>
           <DataTemplate>
                <ViewCell>
                     <Label Text="{Binding sectionHeader}" TextColor="Red" FontAttributes="Italic" />
                </ViewCell> 
           </DataTemplate>
      </ListView.GroupHeaderTemplate>
      <ListView.ItemTemplate>
      ...
      </ListView.ItemTemplate>
 </ListView>

现在您可以根据需要设置标签样式。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何更改 Xamarin 中的章节标题字体样式? 的相关文章

随机推荐