Wire up secondary commands for settings etc
This commit is contained in:
@@ -19,11 +19,11 @@
|
||||
</UserControl.Resources>
|
||||
<Button
|
||||
x:Name="Button"
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
Padding="{StaticResource ButtonPadding}"
|
||||
Width="{ThemeResource ButtonWidth}"
|
||||
Height="{ThemeResource ButtonHeight}"
|
||||
Padding="{ThemeResource ButtonPadding}"
|
||||
Command="{x:Bind ViewModel.InvokeCommand}"
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
IsEnabled="False">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
|
||||
@@ -51,6 +51,8 @@ public partial class App :
|
||||
services.AddContentTemplate<PrimaryViewModel, PrimaryView>();
|
||||
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
||||
|
||||
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
||||
|
||||
services.AddTransient<IInitializer, AppInitializer>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
@@ -4,13 +4,24 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
|
||||
<Thickness x:Key="ButtonPadding">0</Thickness>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">40</x:Double>
|
||||
</UserControl.Resources>
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="400" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
</ItemsPanelTemplate>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<None Remove="ApplicationBarView.xaml" />
|
||||
<None Remove="PrimaryView.xaml" />
|
||||
<None Remove="SecondaryView.xaml" />
|
||||
<None Remove="SettingsButtonView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
@@ -53,6 +54,11 @@
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="SettingsButtonView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="SecondaryView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Center"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<Grid Width="300" Background="red">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Hyperbar.Windows;
|
||||
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public partial class SecondaryViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
int index) :
|
||||
ObservableCollectionViewModel<IDisposable>(serviceFactory, mediator, disposer),
|
||||
public partial class SecondaryViewModel :
|
||||
ObservableCollectionViewModel<IDisposable>,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
private int index;
|
||||
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
public SecondaryViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
int index) : base(serviceFactory, mediator, disposer)
|
||||
{
|
||||
this.index = index;
|
||||
this.TemplateFactory = templateFactory;
|
||||
|
||||
Add<SettingsButtonViewModel>();
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.SettingsButtonView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Button Content="dfffffff" />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class SettingsButtonView :
|
||||
UserControl
|
||||
{
|
||||
public SettingsButtonView() =>
|
||||
this.InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class SettingsButtonViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(serviceFactory, mediator, disposer),
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -2,9 +2,15 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public class ObservableViewModel(IDisposer disposer) :
|
||||
public class ObservableViewModel(IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) :
|
||||
ObservableObject,
|
||||
IDisposable
|
||||
{
|
||||
public IServiceFactory ServiceFactory => serviceFactory;
|
||||
|
||||
public IMediator Mediator => mediator;
|
||||
|
||||
public void Dispose() => disposer.Dispose(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user