Add project files.

master
Yik Teng Hie 3 years ago
parent 019a22f7d8
commit eb9081a808

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCommunityApp", "MvvmCommunityApp\MvvmCommunityApp.csproj", "{A9F79E7F-91A0-4A7D-B2AD-2AF6D3C80B4B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9F79E7F-91A0-4A7D-B2AD-2AF6D3C80B4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9F79E7F-91A0-4A7D-B2AD-2AF6D3C80B4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9F79E7F-91A0-4A7D-B2AD-2AF6D3C80B4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9F79E7F-91A0-4A7D-B2AD-2AF6D3C80B4B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {96898E25-7C9A-4948-BC13-A8E9A0307BBB}
EndGlobalSection
EndGlobal

@ -0,0 +1,8 @@
<Application x:Class="MvvmCommunityApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MvvmCommunityApp">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,35 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using MvvmCommunityApp.interfaces;
using MvvmCommunityApp.services;
using MvvmCommunityApp.viewmodels;
using System.Windows;
namespace MvvmCommunityApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// setup mvvm ioc
Ioc.Default.ConfigureServices(
new ServiceCollection()
.AddTransient<IocPageViewModel>()
.AddSingleton<IDemoService, DemoService>()
.BuildServiceProvider());
// load the main / entry page
MainWindow wnd = new MainWindow();
wnd.Title = "Something else";
wnd.Show();
}
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,14 @@
<Window x:Class="MvvmCommunityApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmCommunityApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel>
<TextBlock Text="{Binding MyName}" />
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,33 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using MvvmCommunityApp.viewmodels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MvvmCommunityApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = Ioc.Default.GetRequiredService<IocPageViewModel>();
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="views\" />
</ItemGroup>
</Project>

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MvvmCommunityApp.interfaces
{
public interface IDemoService
{
string Name { get; }
void Show(string name);
}
}

@ -0,0 +1,19 @@
using MvvmCommunityApp.interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MvvmCommunityApp.services
{
public class DemoService : IDemoService
{
public string Name { get; set; }
public void Show(string name)
{
Console.WriteLine(name);
}
}
}

@ -0,0 +1,20 @@
using MvvmCommunityApp.interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MvvmCommunityApp.viewmodels
{
public class IocPageViewModel : SamplePageViewModel
{
public string MyName { get; set; }
public IocPageViewModel(IDemoService demoService)
: base(demoService)
{
MyName = "Ioc";
}
}
}

@ -0,0 +1,15 @@
using CommunityToolkit.Mvvm.ComponentModel;
using MvvmCommunityApp.interfaces;
namespace MvvmCommunityApp.viewmodels
{
public class SamplePageViewModel : ObservableObject
{
private readonly IDemoService _demoService;
public SamplePageViewModel(IDemoService demoService)
{
_demoService = demoService;
}
}
}
Loading…
Cancel
Save