❔ [AvaloniaUI] Visibility of item in ListView based on condition
An Avalonia UI application is used to manage an evidence of items. It allows the user to add items. or remove them.
The View displays a list of items in a
ListView
. The Item
model represents an item in the evidence. The ViewModel for the View handles retrieving the list of Item
instances. The View binds the observable list of Item
instances to the ListView
.
The goal is to show the Remove button as part of a ListViewItem
, but only when that given item in the ListView
is selected.
My idea is to only handle the collection of Item
instances and the currently selected Item
in the ViewModel, while the View would do the rest.
I wanted to accomplish it via a Converter, that would receive the templated Item
and the currently selected Item
.
However, after fighting with it for some time, I was unable to make it work.
Is my thinking correct - should the View be responsible for handling the Remove button visibility? Should it be done in the ViewModel?2 Replies
I confess, that the current converter implementation and use is incorrect; however, I wish to hear some of your advice, before I continue mashing my head against the wall to find the correct solution.
The main question is whether my approach is even correct
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.