如何在Xamarin中更改版块标题字体样式? [英] How can I change Section Title Font Style in Xamarin?

查看:91
本文介绍了如何在Xamarin中更改版块标题字体样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此列表视图,但我不知道如何设置节标题的样式.如何在Xamarin中完成?没找到任何东西

I have this list view but i dont know how to set style for the section titles. How can it be done in Xamarin? Have not found anything for that

<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>

推荐答案

您将要在DataTemplate中将ListView.GroupHeaderTemplateViewCell一起使用.例如:

You will want to use a 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>

现在,您可以随意设置标签样式.

Now you can just style the Label however you want.

这篇关于如何在Xamarin中更改版块标题字体样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆