Make custom widgets independent of any WinUI framework concerns. Although one can add WinUI concerns to ther widget if they want to build a fully customized widget. In theory, it may also be possible to host a widget of WPF, Avalonia, or Blazor.

This commit is contained in:
TheXamlGuy
2024-01-06 09:57:23 +00:00
parent 3e88950669
commit 4a27534e39
41 changed files with 218 additions and 205 deletions
+8 -10
View File
@@ -1,6 +1,4 @@
using Hyperbar.Windows.Contextual;
using Hyperbar.Windows.Controls;
using Hyperbar.Windows.Primary;
using Hyperbar.Windows.Controls;
using Hyperbar.Lifecycles;
using Hyperbar.Templates;
using Microsoft.Extensions.Configuration;
@@ -38,19 +36,19 @@ public partial class App :
services.AddTransient<ITemplateFactory, TemplateFactory>();
services.AddTransient<ITemplateGeneratorFactory, TemplateGeneratorFactory>();
services.AddDataTemplate<CommandViewModel, CommandView>();
services.AddContentTemplate<CommandViewModel, CommandView>();
services.AddCommand<ContextualCommandWidgetBuilder>("");
services.AddCommand<PrimaryCommandWidgetBuilder>("");
//services.AddCommand<ContextualCommandWidgetBuilder>("");
//services.AddWidget<PrimaryCommandWidgetBuilder>("");
services.AddTransient(provider =>
{
static IEnumerable<ICommandWidgetViewModel> Resolve(IServiceProvider services)
static IEnumerable<IWidgetViewModel> Resolve(IServiceProvider services)
{
foreach (ICommandWidgetContext commandContext in services.GetServices<ICommandWidgetContext>())
foreach (IWidgetContext commandContext in services.GetServices<IWidgetContext>())
{
if (commandContext.ServiceProvider.GetService<ICommandWidgetViewModel>() is
ICommandWidgetViewModel commandViewModel)
if (commandContext.ServiceProvider.GetService<IWidgetViewModel>() is
IWidgetViewModel commandViewModel)
{
yield return commandViewModel;
}