Posts

Showing posts with the label listview

WPF: How to data bind a ComboBox to ListView selection and set the ComboBox value range?

WPF: How to data bind a ComboBox to ListView selection and set the ComboBox value range? I'm new in WPF land and have the following question regarding data binding. My test app contains a ListView with cars (Colums: Type, Speed and Color). Below the list view there are some controls to control the selected car's values. Among others there's a ComboBox to choose the selected car's color. My test app looks like this In XAML the ListView is initialized like this: <ListView Grid.Row="1" Name="listView" ItemsSource="{Binding Model.Cars}" SelectedValue="{Binding Model.SelectedCar}"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header="Type" Width="Auto" DisplayMemberBinding="{Binding Name}" /> <GridViewColumn Header="Speed" Width="Auto" DisplayMemberBinding="{Binding Speed}" /> <Gri...

RecycylerView with SortedList shows duplicate items

RecycylerView with SortedList shows duplicate items I use an SortedList with a RecyclerViewAdapter for my list. Therefore I send my items (loaded from my backend in a background thread) via an listener to my GameListAdapter . According to the implemented logic in my SortedListAdapterCallback items sent to the adapter with the same id should be replaced instead of being inserted multiple times. Unfortunately this is mainly, but not always the case. SortedList RecyclerViewAdapter GameListAdapter SortedListAdapterCallback This is the constructor of my GameListAdapter GameListAdapter public GameListAdapter(RecyclerView list) { this.list = list; gamelistItems = new SortedList<>(GameListItem.class, new SortedListAdapterCallback<GameListItem>(this) { @Override public int compare(GameListItem o1, GameListItem o2) { return o1.getDate().compareTo(o2.getDate()); } @Override public boolean areContentsTheSame(GameListItem ol...