You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The top ItemsRepeater is trying to bind the item to the DataContext of the ItemView and is not working
2b. The bottom ItemsRepeater is directly using the Bindings on the ItemView and are working
Inspect the ItemView and DataContext will be set to TestItemsRepeater.ViewModels.MainWindowViewModel
Optional 4. Downgrade Avalonia to 11.0.11 and run. Both ItemsRepeater will now work properly
Expected behavior
The DataContext of the ItemView should be set to TestItemsRepeater.ViewModels.ItemViewModel as it used to do in 11.0.11
Avalonia version
11.1.0-rc2
OS
Windows
Additional context
I tested this same setup using ItemControl and that does not seem to have this issue
The text was updated successfully, but these errors were encountered:
I've tested both versions (11.0.11 and 11.1.0-rc2) and it is a regression. However, there's no need to assign the DataContext to what you're expecting to be...itself?
Change to <views:ItemView /> and it will work as expected.
The root element's concept of what the DataContext is seems to have broken (in only ItemsRepeater, ItemsControl works fine). This may be a problem for a niche case where you need to bind DataContext properties of the Item VM to the root control in the ItemTemplate. In that scenario, you would need a wrapper so it's not the root:
Describe the bug
Using
"{Binding}"
insideItemsRepeater.DataTemplate
is binding to the Parent, not to the Item.To Reproduce
Test case project: TestItemsRepeater.zip
ItemsRepeater
is trying to bind the item to the DataContext of theItemView
and is not working2b. The bottom
ItemsRepeater
is directly using the Bindings on theItemView
and are workingItemView
andDataContext
will be set toTestItemsRepeater.ViewModels.MainWindowViewModel
Optional 4. Downgrade Avalonia to
![TestItemsRepeater_UjC1DurtC1](https://private-user-images.githubusercontent.com/16965382/346155516-6470906b-b5b7-499e-bf50-76756d6c4ce3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MjY0NTgsIm5iZiI6MTcyMDUyNjE1OCwicGF0aCI6Ii8xNjk2NTM4Mi8zNDYxNTU1MTYtNjQ3MDkwNmItYjViNy00OTllLWJmNTAtNzY3NTZkNmM0Y2UzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDExNTU1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc3ZTZkMDg3ZmZjNDk2MDhhNzgwYzE0ZWUwZDBjMDE5OGQwZDQxZjYwYjNjYmFlZDcxZDExYTlmYjQzY2Y5YTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vSitih_HT1XK9E3BJHDW02dMl8Lr9UdvhwraeLuUekI)
11.0.11
and run. BothItemsRepeater
will now work properlyExpected behavior
The
DataContext
of theItemView
should be set toTestItemsRepeater.ViewModels.ItemViewModel
as it used to do in11.0.11
Avalonia version
11.1.0-rc2
OS
Windows
Additional context
I tested this same setup using ItemControl and that does not seem to have this issue
The text was updated successfully, but these errors were encountered: