DataTemplateSelector.SelectTemplateCore is passed a different "container" parameter on Desktop vs. WinwodwsAppSDK, Wasm, Android #16589
Labels
area/skia ✏️
Categorizes an issue or PR as relevant to Skia
difficulty/tbd
Categorizes an issue for which the difficulty level needs to be defined.
kind/bug
Something isn't working
project/layout 🧱
Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)
Current behavior
I have a ContentControl which utilizes a DataTemplateSelector to select one of several templates depending on the type of content (ViewModel) it is bound to. On WindowsAppSKD, Android, and Wasm (and presumably iOS though I have not tested) DataTemplateSelector.SelectTemplateCore is passed the ContentControl as the container. On Desktop, that method is passed the ContentPresenter used by the ContentControl as a container.
Expected behavior
All platforms to behave the same, and the same as WindowsAppSDK.
How to reproduce it (as minimally and precisely as possible)
Minimal repro:
UnoApp25.zip
In this app, MainPage contains two instances of MyContentControl with their Content bound to different types of MyViewModels. MyContentControl uses a different template for each MyViewModel type, selected by a DataTemplateSelector. The commentary in DataTemplateSelector.SelectTemplateCore explains the differences in the incoming "container" parameter on different platforms, and shows the necessary platform dependent code:
Workaround
The platform dependent code shows above does the trick. Nonetheless, the different platforms should all behave the same.
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
{
"msbuild-sdks": {
"Uno.Sdk": "5.2.108"
}
}
Affected platforms
No response
IDE
Visual Studio 2022
IDE version
17.9.3
Relevant plugins
No response
Anything else we need to know?
Affected platforms: Desktop
The text was updated successfully, but these errors were encountered: