Search Unity

Easy List View Official Thread

Discussion in 'Assets and Asset Store' started by joeconstable97, Jun 4, 2019.

  1. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    50
    NOW RELEASED!
    http://u3d.as/1y4h


    Hey all!

    I've made a little tool for Unity that allows users to create lists using Unity's UI system much more easily. I was inspired by how Xamarin and WPF did it, using bindings and Observable Collections.

    I decided to make this tool because I've always found it to be a bit of a pain to quickly create dynamic lists in Unity and wanted to create something that could process much more simple and be used independently in any project.





    Examples:



    Check it out here:

    http://u3d.as/1y4h

    I'd have made this free but I'm currently a student and every little helps ;)
     
    Last edited: Jun 13, 2019
  2. horizontwin_unity

    horizontwin_unity

    Joined:
    Jun 2, 2021
    Posts:
    2
    Hi, can check how do I reload the list view with updated data source? Basically I loaded the list view with a data collection and I tried to refresh the list view with new set of data collection:

    Collection.Clear();
    List.SetBinding(Collection);

    But the code above will create duplicate rows under the list view. Appreciate your help, thanks.
     
  3. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    50
    Hmm, perhaps the clear event isn't been caught properly, have you tried removing each of the elements in collection individually? i.e.
    Code (CSharp):
    1. while(Collection.Count > 0)
    2. {
    3.    Collection.RemoveAt(0);
    4. }
     
  4. horizontwin_unity

    horizontwin_unity

    Joined:
    Jun 2, 2021
    Posts:
    2
    Thanks for your reply. I have tried but it will still show duplicate items. I have fixed it by resetting the collection:
    Collection = new ObservableCollection<iListModel>();
    List.SetBinding(Collection);
     
    joeconstable97 likes this.
  5. AxeAficionado

    AxeAficionado

    Joined:
    Sep 19, 2023
    Posts:
    2
    Hello! Is there a way to search through the collection and rebind only those that match a certain string? For example, if there is a name item, find all that the name item matches and only display those. I have tried the two following statements with no luck.

    Code (CSharp):
    1. membersCol = new ObservableCollection<iListModel>(membersCol.Where(x => String.Equals(((Entry)x).FirstName, search, StringComparison.InvariantCulture)));
    Code (CSharp):
    1. membersCol = new ObservableCollection<iListModel>(membersCol.Where(x => ((Entry)x).FirstName.StartsWith(search)));
     
  6. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    50
    Hi, thanks for the question. This is untested so I could be wrong about this but...
    Re-assigning the ObservableCollection messes with the callback used internally.
    Have you tried something like?
    Code (CSharp):
    1. membersCol.Clear();
    2. var newList = membersCol.Where(x => String.Equals(((Entry)x).FirstName, search, StringComparison.InvariantCulture));
    3. membersCol.AddRange(newList);
     
  7. AxeAficionado

    AxeAficionado

    Joined:
    Sep 19, 2023
    Posts:
    2
    That got me where I needed. Thanks for the reply and assistance!
     
    joeconstable97 likes this.