thebrowsercompany / windows-samples

Sample Apps for Swift on Windows
MIT License
262 stars 13 forks source link

Using `ListView`s with `itemsSource` #19

Open paulvarache opened 1 month ago

paulvarache commented 1 month ago

Hi,

I've been successfully using this repo to work on a windows app using swift. I am trying to use the ListView with its itemsSource property. Looking at the WinRT API reference the itemsSource should implement IObservableVector, I found bindings for ItemCollection which implements it, but can't find a way to provide the data for it.

Looking at the toVector extension provided I tried implementing a toObservableVector but the swift toolchain crashes while trying to build:

SIL verification failed: public/package/shared function must have a body: F->isDefinition() || F->hasForeignBody()
In function:
// IVector.subscript.read
sil shared [serialized] @$s17WindowsFoundation7IVectorPAAEy7ElementQzSicir : $@yield_once @convention(method) <τ_0_0 where τ_0_0 : IVector> (Int, @guaranteed τ_0_0) -> @yields @in_guaranteed τ_0_0.Element

I actually get the same result if I just copy over the contents of the ARRAY+TOVECTOR file, which makes me think those types of Support file need to be compiled with different settings than source files for an app.

I'm not too versed in either swift or WinRT bindings for swift so I'm making a lot of assumptions here.

I assume the BCNY team found a solution to use ListViews (or any ItemsControl) with itemsSource. Unless you don't use the virtualisation and provide items directly?

Thanks again for creating such a project and opening it up to the world!