Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneWay x:Bind on ListView.ItemsSource resets the source property if a setter is available #13433

Open
jeromelaban opened this issue Aug 28, 2023 · 1 comment
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine

Comments

@jeromelaban
Copy link
Member

jeromelaban commented Aug 28, 2023

The Control:

        <ListView  ItemsSource="{x:Bind Items,Mode=OneWay}">
            <ListView.ItemTemplate>
               <TextBlock Text="{x:Bind }"/>
            </ListView.ItemTemplate>
        </ListView>

Data :

        publicObservableCollection<Item> Items { set; get; }  ,

In Constructor :

Items = new ObservableCollection<Item>(data_array);

Display Result:
no Item is displayed, but the Items actually have data . I also tried to use ListView.Items property in xaml ,it can correctly work.

Android (7.0) and WASM(firefox-latest) meet this error , WinUI is correct

Repro:
13433-ErrorProject-master.zip

Workaround

The workaround for this particular sample is to remove the ,Mode=OneWay from the ItemsSource binding, which is not needed (ItemsSource is never updated by ListView itself).

Other

Originally posted by @DJDQfff in #13428

@jeromelaban jeromelaban added area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine area/listview 📃 Categorizes an issue or PR as relevant to the ListView control kind/bug Something isn't working labels Aug 28, 2023
@FrozDark
Copy link

FrozDark commented Aug 29, 2023

May be related to #11606

@MartinZikmund MartinZikmund added the difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine
Projects
None yet
Development

No branches or pull requests

3 participants