DataTemplate::LoadContent returns an object with an extra ref count #3057
Labels
bug
Something isn't working
needs-winui-3
Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)
See #1954 for more information, but the problem is that DataTemplate::LoadContent returns an extra reference on the peer object that it retuns. LoadContent and XamlReader::Load do similar things but XamlReader::Load (in the LoadImpl method) calls UnpegNoRef() which takes care of this extra reference. LoadContent doesn't have this and as a result the object returned to callers has a ref count of 2 on it and there's no obvious way to fix this extra reference.
In ItemsRepeater I'm proposing we work around this by adding the object to a Panel's Children collection and immediately removing it, but we should fix this so we don't need that work around with WinUI 3.0.
The text was updated successfully, but these errors were encountered: