ContentView: Setting the ControlTemplate dynamically causes the control to disappear #4135
Labels
area-xaml
XAML, CSS, Triggers, Behaviors
delighter
fixed-in-6.0.400
Look for this fix in 6.0.400!
high
It doesn't work at all, crashes or has a big impact.
p/2
Work that is important, but is currently not scheduled for release
partner
Issue or Request from a partner team
platform/android 🤖
platform/iOS 🍎
platform/macOS 🍏
macOS / Mac Catalyst
platform/windows 🪟
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
I have noticed that
ContentView
does not support setting theControlTemplate
dynamically at runtime. When theControlTemplate
is set initially in XAML or in thePage
's constructor, everything works as expected. When theControlTemplate
is set at a later stage, theContentView
just disappears. Some preliminary investigation leads me to conclude this has something to do with theContentView
sHandler
. If theHandler
is not created yet, setting theControlTemplate
would work as expected. If theHandler
is already created, setting theControlTemplate
would make the control disappear.While debugging, I have also noticed the
ContentView
inherits from the legacyLayout
class. Setting theControlTemplate
at runtime would invalidate the measure, but callingIView.Measure
after that on theContentView
would always return a zeroSize
. This might be some incompatibility between the old and the new layout systems, but I have not investigated that further.Steps to Reproduce
ContentView
has aControlTemplate
set in XAMLContentView
has a customStyle
specifying aControlTemplate
in XAMLContentView
s do not have aControlTemplate
specified initiallySet Custom Template
buttonControlTemplate
to the thirdContentView
. Notice theContentView
disappearing.Set Custom Style
buttonStyle
specifying aControlTemplate
to the fourthContentView
. Notice theContentView
disappearing.Version with bug
Preview 11
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
I have not tested on various versions of the different platforms.
Did you find any workaround?
The only workaround I have found so far is to replace the
ContentView
with a new instance, that has the desiredControlTemplate
set initially. This is rather inconvenient, as changing theStyle
of aContentView
to a new one, which might potentially update theControlTemplate
, would require re-creating the entireContentView
every time, to avoid the bug.Relevant log output
No log output available at this time.
Sample project
TestApp.zip
The text was updated successfully, but these errors were encountered: