Browse Source

Add datacontext

pull/5/head
Ionite 2 years ago
parent
commit
2ce129a485
No known key found for this signature in database
  1. 8
      StabilityMatrix/A3WebUI.cs
  2. 8
      StabilityMatrix/BasePackage.cs
  3. 22
      StabilityMatrix/InstallPage.xaml
  4. 14
      StabilityMatrix/InstallPage.xaml.cs
  5. 16
      StabilityMatrix/InstallerViewModel.cs

8
StabilityMatrix/A3WebUI.cs

@ -0,0 +1,8 @@
namespace StabilityMatrix;
public class A3WebUI: BasePackage
{
public override string Name => "stable-diffusion-webui";
public override string DisplayName => "Stable Diffusion WebUI";
public override string Author => "AUTOMATIC1111";
}

8
StabilityMatrix/BasePackage.cs

@ -0,0 +1,8 @@
namespace StabilityMatrix;
public abstract class BasePackage
{
public abstract string Name { get; }
public abstract string DisplayName { get; }
public abstract string Author { get; }
}

22
StabilityMatrix/InstallPage.xaml

@ -7,28 +7,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="using:System"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
d:DataContext="{d:DesignInstance Type=local:InstallerViewModel}">
<Grid>
<Grid.Resources>
<local:Package x:Key="ItemsViewSource" />
</Grid.Resources>
<Page.DataContext>
<local:InstallerViewModel/>
</Page.DataContext>
<Grid>
<ListView x:Name="ItemListView"
Margin="120,0,0,60"
ItemsSource="{x:Bind packages}"
BorderThickness="1"
BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
Width="350"
Height="400"
HorizontalAlignment="Left">
<ListView.ItemsSource>
<Binding Path="Packages" />
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Package">
<DataTemplate x:DataType="local:BasePackage">
<Grid Height="110" Margin="6">
<StackPanel Grid.Column="0" VerticalAlignment="Top" Margin="10,0,0,0">
<TextBlock Text="{x:Bind Name}" x:Phase="1" Margin="0,5,0,5"></TextBlock>
<TextBlock Text="{x:Bind DisplayName}" x:Phase="1" Margin="0,5,0,5" Style="{ThemeResource BaseTextBlockStyle}" />
<TextBlock Text="{x:Bind Author}" x:Phase="2" Margin="0,0,0,5" Style="{ThemeResource BodyTextBlockStyle}" />
</StackPanel>
</Grid>
</DataTemplate>

14
StabilityMatrix/InstallPage.xaml.cs

@ -27,20 +27,10 @@ namespace StabilityMatrix
/// </summary>
public sealed partial class InstallPage : Page
{
private readonly ObservableCollection<Package> packages = new()
{
new Package() { Name = "Automatic 1111" }
};
public InstallPage()
{
this.InitializeComponent();
InitializeComponent();
DataContext = new InstallerViewModel();
}
}
public class Package
{
public string Name { get; set; }
}
}

16
StabilityMatrix/InstallerViewModel.cs

@ -0,0 +1,16 @@
using System.Collections.ObjectModel;
namespace StabilityMatrix;
internal class InstallerViewModel
{
public InstallerViewModel()
{
}
public static ObservableCollection<BasePackage> Packages => new()
{
new A3WebUI(),
};
}
Loading…
Cancel
Save