void UpdateContent(Cell newCell) { Microsoft.UI.Xaml.DataTemplate dt = GetTemplate(newCell); if (dt != _currentTemplate || Content == null) { _currentTemplate = dt; Content = dt.LoadContent(); } ((FrameworkElement)Content).DataContext = newCell; }
public static DataTemplate DataTemplate <TRootUI>(Action <Xaml.DependencyObject> build) where TRootUI : Xaml.UIElement, new() { #if WINUI // Note that we cannot pass markup objects to the build action here, because we get the ui type instance. var ui = (Xaml.DataTemplate)CreateTemplate(nameof(Xaml.DataTemplate), typeof(TRootUI), true, ConfigureRoot.CreateIdFor(build)); #else var ui = new Xaml.DataTemplate(() => { var root = new TRootUI(); build(root); return(root); }); #endif return(CSharpMarkup.WinUI.DataTemplate.StartChain(ui)); }
public static DataTemplate DataTemplate <TRootUI>(Func <UIElement> build) where TRootUI : Xaml.Controls.Panel, new() { #if WINUI var ui = (Xaml.DataTemplate)CreateTemplate(nameof(Xaml.DataTemplate), typeof(TRootUI), false, BuildChild.CreateIdFor(build)); #else var ui = new Xaml.DataTemplate(() => { var root = new TRootUI(); var child = build(); root.Children.Add(child.UI); return(root); }); #endif return(CSharpMarkup.WinUI.DataTemplate.StartChain(ui)); }
public ShellFlyoutTemplateSelector() { BaseShellItemTemplate = (Microsoft.UI.Xaml.DataTemplate)Microsoft.UI.Xaml.Application.Current.Resources["ShellFlyoutBaseShellItemTemplate"]; MenuItemTemplate = (Microsoft.UI.Xaml.DataTemplate)Microsoft.UI.Xaml.Application.Current.Resources["ShellFlyoutMenuItemTemplate"]; SeperatorTemplate = (Microsoft.UI.Xaml.DataTemplate)Microsoft.UI.Xaml.Application.Current.Resources["ShellFlyoutSeperatorTemplate"]; }