A widget should have only one IWidgetViewModel by default... wondering whether if we should go for the first served, or throw if multiple detected, or ignore the widget

This commit is contained in:
TheXamlGuy
2024-01-30 22:30:08 +00:00
parent 215ff81653
commit 858a23c28d
14 changed files with 139 additions and 180 deletions
@@ -10,7 +10,7 @@ public static class IServiceCollectionExtensions
{
public static IServiceCollection AddWidgetWindows(this IServiceCollection services)
{
services.AddContentTemplate<WidgetBarViewModel, WidgetBarView>();
services.AddContentTemplate<WidgetViewModel, WidgetBarView>();
// We need to feed information to the Widgets about our Windows host,
// so the Windows host can make discussions how to display and interact with the widgets.
@@ -20,8 +20,6 @@ public static class IServiceCollectionExtensions
{
services.AddSingleton(provider.GetRequiredService<IList<IXamlMetadataProvider>>());
services.AddSingleton(provider.GetRequiredService<IDispatcher>());
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>,
WidgetContainerFactory>();
services.AddTransient<ITemplateFactory, TemplateFactory>();
@@ -35,7 +33,6 @@ public static class IServiceCollectionExtensions
services.AddTransient<IInitializer, WidgetResourceInitializer>();
services.AddTransient<IInitializer, WidgetXamlMetadataInitializer>();
services.AddContentTemplate<WidgetContainerViewModel, WidgetContainerView>();
services.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
services.AddContentTemplate<WidgetSplitButtonViewModel, WidgetSplitButtonView>();
}));
@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="Hyperbar.Widget.Windows.WidgetContainerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:ui="using:Hyperbar.UI.Windows">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle
Width="1"
Height="40"
Margin="6,2,6,2"
Fill="Red" />
<ItemsControl
Grid.Column="1"
ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}"
ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Loaded">
<interactions:InvokeCommandAction Command="{Binding Initialize}" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</ItemsControl>
</Grid>
</UserControl>
@@ -1,9 +0,0 @@
using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.Widget.Windows;
public sealed partial class WidgetContainerView :
UserControl
{
public WidgetContainerView() => InitializeComponent();
}