Skip to content

Commit 9c28c4c

Browse files
committed
hmm...
1 parent 693ae30 commit 9c28c4c

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

SimpleMVVM.Example/Elements.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace SimpleMVVM.Example;
2+
3+
public record struct Element(string Name, string Description) : INamed;
4+
[Singleton]
5+
public partial class Elements : IContent<Element>
6+
{
7+
public Element[] All { get; } =
8+
[
9+
new Element("Element 1", "Description of Element 1"),
10+
new Element("Element 2", "Description of Element 2"),
11+
new Element("Element 3", "Description of Element 3"),
12+
new Element("Element 4", "Description of Element 4"),
13+
new Element("Element 5", "Description of Element 5")
14+
];
15+
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
namespace SimpleMVVM.Example;
22

3-
[Singleton, ViewModel]
3+
[Singleton][ViewModel]
44
public partial class MainViewModel
55
{
66
[Command]
77
public void ShowMessage() => System.Windows.MessageBox.Show("Hello, World!");
8+
9+
[Command]
10+
public void ShowElements()
11+
{
12+
var elements = App.Get<Elements>().All;
13+
System.Windows.MessageBox.Show(string.Join("\n", elements.Select(e => $"{e.Name}: {e.Description}")));
14+
}
815
}

SimpleMVVM.Example/MainWindow.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
mc:Ignorable="d"
99
Title="MainWindow" Height="450" Width="800">
1010
<Grid>
11+
<StackPanel>
1112
<Button Content="Show Message" Command="{Binding ShowMessageCommand}" Height="200" Width="300"/>
12-
13+
<Button Content="Show Elements" Command="{Binding ShowElementsCommand}" Height="200" Width="300"/>
14+
</StackPanel>
1315
</Grid>
1416
</Window>

SimpleMVVM.Example/SimpleMVVM.Example.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<ProjectReference Include="..\SimpleMVVM\SimpleMVVM.csproj" />
16+
<Reference Include="SimpleMVVM">
17+
<HintPath>..\SimpleMVVM\bin\Release\net9.0-windows\SimpleMVVM.dll</HintPath>
18+
</Reference>
1719
</ItemGroup>
1820

1921
</Project>

0 commit comments

Comments
 (0)