Fixed InitializationScoped

This commit is contained in:
Dan Clark
2024-12-05 16:11:48 +00:00
parent 6454e1bb6f
commit 8bbfc415e6
3 changed files with 35 additions and 5 deletions
@@ -50,6 +50,18 @@ public static class ContentTemplateBinding
{
cachedActivation = null;
content.Unloaded -= HandleUnloaded;
content.DataContextChanged -= HandleDataContextChanged;
}
}
void HandleDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
{
if (sender is FrameworkElement content)
{
if (content.DataContext is IActivation activation)
{
activation.IsActive = true;
}
}
}
@@ -57,11 +69,13 @@ public static class ContentTemplateBinding
{
content.Loaded += HandleLoaded;
content.Unloaded += HandleUnloaded;
content.DataContextChanged += HandleDataContextChanged;
}
else
{
content.Loaded -= HandleLoaded;
content.Unloaded -= HandleUnloaded;
content.DataContextChanged -= HandleDataContextChanged;
}
}
}