File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed
Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 11namespace SimpleMVVM . Example ;
22
3- [ Singleton , ViewModel ]
3+ [ Singleton ] [ ViewModel ]
44public 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}
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments