Files
Hyperbar/Hyperbar.UI.Windows/TemplateGeneratorControl.cs
T
TheXamlGuy 731cf3cdf3 More work
2024-02-04 14:08:38 +00:00

22 lines
558 B
C#

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.UI.Windows;
public class TemplateGeneratorControl :
ContentControl
{
public TemplateGeneratorControl()
{
DataContextChanged += OnDataContextChanged;
}
private void OnDataContextChanged(FrameworkElement sender,
DataContextChangedEventArgs args)
{
if (DataContext is ITemplatedViewModel templatedViewModel)
{
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
}
}
}