add MvvmAppUi class library

master
Yik Teng Hie 3 years ago
parent 2b6f1a2cdc
commit ea22a95348

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MvvmAppCore.Models
{
internal class MotorProfile
{
}
}

@ -0,0 +1,15 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace MvvmAppCore.ViewModels
{
public partial class MotorProfileViewModel : ObservableObject
{
[ObservableProperty]
private string _motorName;
public MotorProfileViewModel()
{
MotorName = "Elevator";
}
}
}

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MvvmAppCore\MvvmAppCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,38 @@
<UserControl x:Class="MvvmAppUi.Views.MotorProfileView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MvvmAppUi.Views"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<!-- Content -->
<Grid Grid.Column="1">
<TextBlock Text="{Binding MotorName}" />
</Grid>
<Grid Grid.Column="1"
Grid.Row="2"
Grid.ColumnSpan="2">
<StackPanel Orientation="Horizontal">
<Button Content="OK"
Margin="5"
HorizontalContentAlignment="Stretch" />
<Button Content="Cancel"
Margin="5"
HorizontalContentAlignment="Stretch" />
</StackPanel>
</Grid>
</Grid>
</UserControl>

@ -0,0 +1,19 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using MvvmAppCore.ViewModels;
using System.Windows.Controls;
namespace MvvmAppUi.Views
{
/// <summary>
/// Interaction logic for MotorProfileView.xaml
/// </summary>
public partial class MotorProfileView : UserControl
{
public MotorProfileView()
{
InitializeComponent();
DataContext = Ioc.Default.GetRequiredService<MotorProfileViewModel>();
}
}
}

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCommunityApp", "MvvmCom
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmAppCore", "MvvmAppCore\MvvmAppCore.csproj", "{8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmAppCore", "MvvmAppCore\MvvmAppCore.csproj", "{8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmAppUi", "MvvmAppUi\MvvmAppUi.csproj", "{E0548A3E-F7A4-4BEE-A5DC-A62AACA38C12}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Release|Any CPU.Build.0 = Release|Any CPU {8CFB1DAE-0565-4A86-B0CC-2D7E3C9ED053}.Release|Any CPU.Build.0 = Release|Any CPU
{E0548A3E-F7A4-4BEE-A5DC-A62AACA38C12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0548A3E-F7A4-4BEE-A5DC-A62AACA38C12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0548A3E-F7A4-4BEE-A5DC-A62AACA38C12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0548A3E-F7A4-4BEE-A5DC-A62AACA38C12}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -29,6 +29,7 @@ namespace MvvmCommunityApp
.AddTransient<IocPageViewModel>() .AddTransient<IocPageViewModel>()
.AddSingleton<IDemoService, DemoService>() .AddSingleton<IDemoService, DemoService>()
.AddSingleton<MainWindowViewModel>() .AddSingleton<MainWindowViewModel>()
.AddSingleton<MotorProfileViewModel>()
.BuildServiceProvider()); .BuildServiceProvider());
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)

@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmCommunityApp" xmlns:local="clr-namespace:MvvmCommunityApp"
xmlns:vm="clr-namespace:MvvmAppUi.Views;assembly=MvvmAppUi"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="MainWindow" Height="450" Width="800">
<Grid> <Grid>
@ -14,6 +15,7 @@
<Button Content="Update" <Button Content="Update"
Command="{Binding UpdateCommand}" /> Command="{Binding UpdateCommand}" />
<TextBlock Text="{Binding Customer}" /> <TextBlock Text="{Binding Customer}" />
<vm:MotorProfileView />
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

@ -18,6 +18,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MvvmAppCore\MvvmAppCore.csproj" /> <ProjectReference Include="..\MvvmAppCore\MvvmAppCore.csproj" />
<ProjectReference Include="..\MvvmAppUi\MvvmAppUi.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Loading…
Cancel
Save