如何在Xamarin中更改Section Title字体样式?

时间:2016-12-06 21:21:16

标签: listview xamarin xamarin.forms

我有这个列表视图,但我不知道如何设置节标题的样式。如何在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>

1 个答案:

答案 0 :(得分:1)

您需要在ViewCell中使用DataTemplate <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> 。 E.g:

for sublist in np_combined:
    if max(sublist) > 5:
        plt.plot(times,sublist,color = 'blue')
    else:
        plt.plot(times,sublist,color = 'orange')

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