使用ListView

基本功能

使用MVVM架構

ViewModel 基本的參考 (Ref)

群組

  1. 在helper目錄下,新增 Group 自定的方法
  2. 調整資料來源,轉換成支援Group的 ObservableCollection
  3. 設定XAML頁面,指定GroupDisplay的屬性

https://github.com/jamesmontemagno/Xamarin.Forms-Monkeys/tree/master/Monkeys/Monkeys http://motzcod.es/post/94643411707/enhancing-xamarinforms-listview-with-grouping https://mallibone.com/post/xamarin.forms-grouped-listview https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/ListView/Grouping

如果要客製Header可參考以下文章 https://mallibone.com/post/xamarin.forms-grouped-listview

<ListView.GroupHeaderTemplate>
    <DataTemplate>
      <ViewCell>
        <StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
                     BackgroundColor="Navy">
          <Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
            <Label Text="{Binding Key}" FontSize="Small" TextColor="Lime" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
          </Grid>
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.GroupHeaderTemplate>

加入Checkbox功能

Hint: 目前Xamarin官方沒有支援,可參考以下二個範例,進行實作

  1. Using a Native Custom Control with Xamarin.Forms via a Custom Renderer (Ref)
  2. XLabs Checkbox (Ref)

results matching ""

    No results matching ""