Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

c# - Passing and binding multiple Strings and ObservableCollection to RefreshView / CollectionView?

Fairly new to Xamarin Forms with a lot of background in C# ASP.Net MVC background. I am wondering what the best pattern would be in Xamarin Forms to pass more complex data models to a xaml view. What I am trying to achieve is passing the following data model:

String DateHeader
ObservableCollection<CustomObject>
String DateHeader
ObservableCollection<CustomObject>
String DateHeader
ObservableCollection<CustomObject>
String DateHeader
ObservableCollection<CustomObject>
String DateHeader
ObservableCollection<CustomObject>

To a RefreshView collection:

<RefreshView IsRefreshing="{Binding IsRefreshing}" Command="{Binding GetCustomObjectModelCommand}">
    <CollectionView ItemsSource="{Binding CustomObjectModel}">
        <CollectionView.ItemsLayout>
            <LinearItemsLayout Orientation="Vertical"/>
        </CollectionView.ItemsLayout>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <StackLayout Padding="10">
                    // Data goes here
                </StackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</RefreshView>

I currently have a model of single ObservableCollection passing back and binding working fine. In ASP.Net MVC I'd just had each and loop in the view, but trying to figure out how that is achieved in Xamarin Forms since there is less view logic.

The goal for the UI output would be something like:

Date Header

  • list collection item
  • list collection item
  • list collection item
  • list collection item
  • list collection item

Date Header

  • list collection item
  • list collection item
  • list collection item
  • list collection item
  • list collection item

Date Header

  • list collection item
  • list collection item
  • list collection item
  • list collection item
  • list collection item

etc....

question from:https://stackoverflow.com/questions/65881305/passing-and-binding-multiple-strings-and-observablecollection-to-refreshview-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...