rewrite ObservableCollectionViewModel

This commit is contained in:
TheXamlGuy
2024-01-10 20:06:52 +00:00
parent d7d90b3d54
commit d6df6c5eb9
4 changed files with 180 additions and 17 deletions
+4 -1
View File
@@ -52,13 +52,16 @@ public partial class App :
{
static IEnumerable<WidgetContainerViewModel> Resolve(IServiceProvider services)
{
int index = 0;
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
{
if (widgetContext.ServiceProvider.GetServices<IWidgetViewModel>() is
IEnumerable<IWidgetViewModel> viewModels)
{
yield return (WidgetContainerViewModel)ActivatorUtilities.CreateInstance(widgetContext.ServiceProvider,
typeof(WidgetContainerViewModel), viewModels);
typeof(WidgetContainerViewModel), viewModels, index % 2 == 0);
index++;
}
}
}
@@ -4,11 +4,24 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="using:Hyperbar.Windows.UI">
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle
Width="1"
Margin="6,0,6,0"
Fill="Red" />
<ItemsControl
Grid.Column="1"
ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}"
ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</UserControl>