answered
2017-10-24 15:32:01 +0800
cor3000 6280 ● 2 ● 7 Hi Maurizio,
I am sorry if this sounds like I am arguing with you (this is not my intention) ... I am just trying to explain what is happening and that your current usage won't bring your desired results.
Besides I can imagine scenarios where shared selection state is useful e.g 2 separate navigation controls (a combobox and a tabbox driven by the same model. Providing 2 redundant controls to choose the current tab in a tabbox) - anyway that's a matter of personal preference whether that's useful or not.
Given that: using a ListModel that implements Selectable only keeps track of a single set of selected items. Shared among both models. That's not a limitation, that's a feature intended to keep a model driven UI in synch.
If you combine the approaches selectedItem + sharing a model you simply implemented redundant state that can get out-of-synch or replicate in a unwanted way.
I am not completely clear how that relates to scrolling... maybe you can provide an example showing where a ListModel is needed for scrolling. A listbox is scrollable when the number of items exceeds the visible listbox body (if limited in size).
If you are referring to a "Load on demand" ListModel then sharing the same ListModel for 2 listboxes may also give unexpected results. If both have different scroll positions, then the same model suddenly has to load elements for visible different ranges. Also there separating the models is preferable in my opinion.
I agree that the approach of using a live list model will serve your purpose best - given the details you shared so far.
Robert