Open HO-COOH opened 3 months ago
Do you have x:Load
set on the element? I think that may be required in order to use XamlMarkupHelper.UnloadObject
.
Do you have
x:Load
set on the element? I think that may be required in order to useXamlMarkupHelper.UnloadObject
.
Adding a x:Load="False"
then loading it in code solves the issue (but please, add it in UnloadObject
's remark section in the doc). This is from the UWP doc about x:Load.
The UI element attributed with x:Load can be loaded and unloaded via code, or using an x:Bind expression.
This says NOTHING about needing to set it to False
then loaded in code, in order to be able to unload. Setting it to True
you will still get the exceptions.
I agree the docs need to be clarified.
Describe the bug
I am trying to unload a child control inside my templated control using
Windows.UI.Xaml.Markup.XamlMarkupHelper.UnloadObject
(UWP) andMicrosoft.UI.Xaml.Markup.XamlMarkupHelper.UnloadObject
(Winui3) as documented here. But I got exceptions:Steps to reproduce the bug
DependencyProperty
calledIsLoading
. And write code whenIsLoading==false
, call this api to unload a component.MainWindow.xaml
, add aToggleSwitch
and this new templated control, bind theIsLoading
to theToggleSwitch.IsOn
。Expected behavior
No response
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.5.5: 1.5.240627000
Windows version
Windows 11 (22H2): Build 22621
Additional context
This issue happens on both UWP & WinUI3. If I am doing anything wrong, please update the documentation!