diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/SubCabinetSolution/SubCabinetSolution.csproj b/SubCabinetSolution/SubCabinetSolution.csproj index 3323ac5..5e54020 100644 --- a/SubCabinetSolution/SubCabinetSolution.csproj +++ b/SubCabinetSolution/SubCabinetSolution.csproj @@ -34,9 +34,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + True + 4.0 @@ -50,6 +70,8 @@ MSBuild:Compile Designer + + MSBuild:Compile Designer @@ -79,6 +101,7 @@ + diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/SubCabinetSolution/SubCabinetSolution.csproj b/SubCabinetSolution/SubCabinetSolution.csproj index 3323ac5..5e54020 100644 --- a/SubCabinetSolution/SubCabinetSolution.csproj +++ b/SubCabinetSolution/SubCabinetSolution.csproj @@ -34,9 +34,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + True + 4.0 @@ -50,6 +70,8 @@ MSBuild:Compile Designer + + MSBuild:Compile Designer @@ -79,6 +101,7 @@ + diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs new file mode 100644 index 0000000..6b8c76f --- /dev/null +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -0,0 +1,18 @@ +using System.Windows; +using GalaSoft.MvvmLight; + +namespace SubCabinetSolution.ViewModel +{ + public class MainViewModel : ViewModelBase + { + public string VersionName { get; set; } + + /// + /// Initializes a new instance of the MainViewModel class. + /// + public MainViewModel() + { + VersionName = "版本号 Ver " + Application.ResourceAssembly.GetName().Version; + } + } +} \ No newline at end of file diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/SubCabinetSolution/SubCabinetSolution.csproj b/SubCabinetSolution/SubCabinetSolution.csproj index 3323ac5..5e54020 100644 --- a/SubCabinetSolution/SubCabinetSolution.csproj +++ b/SubCabinetSolution/SubCabinetSolution.csproj @@ -34,9 +34,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + True + 4.0 @@ -50,6 +70,8 @@ MSBuild:Compile Designer + + MSBuild:Compile Designer @@ -79,6 +101,7 @@ + diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs new file mode 100644 index 0000000..6b8c76f --- /dev/null +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -0,0 +1,18 @@ +using System.Windows; +using GalaSoft.MvvmLight; + +namespace SubCabinetSolution.ViewModel +{ + public class MainViewModel : ViewModelBase + { + public string VersionName { get; set; } + + /// + /// Initializes a new instance of the MainViewModel class. + /// + public MainViewModel() + { + VersionName = "版本号 Ver " + Application.ResourceAssembly.GetName().Version; + } + } +} \ No newline at end of file diff --git a/SubCabinetSolution/ViewModel/ViewModelLocator.cs b/SubCabinetSolution/ViewModel/ViewModelLocator.cs new file mode 100644 index 0000000..cbe9797 --- /dev/null +++ b/SubCabinetSolution/ViewModel/ViewModelLocator.cs @@ -0,0 +1,57 @@ +/* + In App.xaml: + + + + + In the View: + DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}" + + You can also use Blend to do all this with the tool's support. + See http://www.galasoft.ch/mvvm +*/ + +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace SubCabinetSolution.ViewModel +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + public ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + ////if (ViewModelBase.IsInDesignModeStatic) + ////{ + //// // Create design time view services and models + //// SimpleIoc.Default.Register(); + ////} + ////else + ////{ + //// // Create run time view services and models + //// SimpleIoc.Default.Register(); + ////} + + SimpleIoc.Default.Register(); + } + + public MainViewModel Main + { + get { return ServiceLocator.Current.GetInstance(); } + } + + public static void Cleanup() + { + // TODO Clear the ViewModels + } + } +} \ No newline at end of file diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/SubCabinetSolution/SubCabinetSolution.csproj b/SubCabinetSolution/SubCabinetSolution.csproj index 3323ac5..5e54020 100644 --- a/SubCabinetSolution/SubCabinetSolution.csproj +++ b/SubCabinetSolution/SubCabinetSolution.csproj @@ -34,9 +34,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + True + 4.0 @@ -50,6 +70,8 @@ MSBuild:Compile Designer + + MSBuild:Compile Designer @@ -79,6 +101,7 @@ + diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs new file mode 100644 index 0000000..6b8c76f --- /dev/null +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -0,0 +1,18 @@ +using System.Windows; +using GalaSoft.MvvmLight; + +namespace SubCabinetSolution.ViewModel +{ + public class MainViewModel : ViewModelBase + { + public string VersionName { get; set; } + + /// + /// Initializes a new instance of the MainViewModel class. + /// + public MainViewModel() + { + VersionName = "版本号 Ver " + Application.ResourceAssembly.GetName().Version; + } + } +} \ No newline at end of file diff --git a/SubCabinetSolution/ViewModel/ViewModelLocator.cs b/SubCabinetSolution/ViewModel/ViewModelLocator.cs new file mode 100644 index 0000000..cbe9797 --- /dev/null +++ b/SubCabinetSolution/ViewModel/ViewModelLocator.cs @@ -0,0 +1,57 @@ +/* + In App.xaml: + + + + + In the View: + DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}" + + You can also use Blend to do all this with the tool's support. + See http://www.galasoft.ch/mvvm +*/ + +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace SubCabinetSolution.ViewModel +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + public ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + ////if (ViewModelBase.IsInDesignModeStatic) + ////{ + //// // Create design time view services and models + //// SimpleIoc.Default.Register(); + ////} + ////else + ////{ + //// // Create run time view services and models + //// SimpleIoc.Default.Register(); + ////} + + SimpleIoc.Default.Register(); + } + + public MainViewModel Main + { + get { return ServiceLocator.Current.GetInstance(); } + } + + public static void Cleanup() + { + // TODO Clear the ViewModels + } + } +} \ No newline at end of file diff --git a/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs b/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs index f25a708..7128cb8 100644 --- a/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs +++ b/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "AD01C951FCD2993E0ECCB69821F7049E73D39C8DEBF507E903398E4B5AD28E05" +#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D1F125140B90CCC0F65684EA3BB9FB59D4545E918A9580741DF46EBFF6A1777A" //------------------------------------------------------------------------------ // // 此代码由工具生成。 diff --git a/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx new file mode 100644 index 0000000..50745a7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/303056ec-cdd5-45b8-aec2-ff6f5fc9a350.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx new file mode 100644 index 0000000..f1921f7 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/63c02525-df4f-441f-9125-4b14ee5ed63e.vsidx Binary files differ diff --git a/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx new file mode 100644 index 0000000..edc60e6 --- /dev/null +++ b/.vs/SubCabinetSolution/FileContentIndex/c31295d2-5c59-48e9-92a2-3e4dc8017985.vsidx Binary files differ diff --git a/SubCabinetSolution/MainWindow.xaml b/SubCabinetSolution/MainWindow.xaml index 61d2ef2..eba4e58 100644 --- a/SubCabinetSolution/MainWindow.xaml +++ b/SubCabinetSolution/MainWindow.xaml @@ -153,7 +153,7 @@ Margin="0 3" /> /// Interaction logic for MainWindow.xaml @@ -7,7 +9,7 @@ { public MainWindow() { - InitializeComponent(); + this.DataContext = new MainViewModel(); } } } \ No newline at end of file diff --git a/SubCabinetSolution/SubCabinetSolution.csproj b/SubCabinetSolution/SubCabinetSolution.csproj index 3323ac5..5e54020 100644 --- a/SubCabinetSolution/SubCabinetSolution.csproj +++ b/SubCabinetSolution/SubCabinetSolution.csproj @@ -34,9 +34,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + True + 4.0 @@ -50,6 +70,8 @@ MSBuild:Compile Designer + + MSBuild:Compile Designer @@ -79,6 +101,7 @@ + diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs new file mode 100644 index 0000000..6b8c76f --- /dev/null +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -0,0 +1,18 @@ +using System.Windows; +using GalaSoft.MvvmLight; + +namespace SubCabinetSolution.ViewModel +{ + public class MainViewModel : ViewModelBase + { + public string VersionName { get; set; } + + /// + /// Initializes a new instance of the MainViewModel class. + /// + public MainViewModel() + { + VersionName = "版本号 Ver " + Application.ResourceAssembly.GetName().Version; + } + } +} \ No newline at end of file diff --git a/SubCabinetSolution/ViewModel/ViewModelLocator.cs b/SubCabinetSolution/ViewModel/ViewModelLocator.cs new file mode 100644 index 0000000..cbe9797 --- /dev/null +++ b/SubCabinetSolution/ViewModel/ViewModelLocator.cs @@ -0,0 +1,57 @@ +/* + In App.xaml: + + + + + In the View: + DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}" + + You can also use Blend to do all this with the tool's support. + See http://www.galasoft.ch/mvvm +*/ + +using CommonServiceLocator; +using GalaSoft.MvvmLight.Ioc; + +namespace SubCabinetSolution.ViewModel +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + public ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + ////if (ViewModelBase.IsInDesignModeStatic) + ////{ + //// // Create design time view services and models + //// SimpleIoc.Default.Register(); + ////} + ////else + ////{ + //// // Create run time view services and models + //// SimpleIoc.Default.Register(); + ////} + + SimpleIoc.Default.Register(); + } + + public MainViewModel Main + { + get { return ServiceLocator.Current.GetInstance(); } + } + + public static void Cleanup() + { + // TODO Clear the ViewModels + } + } +} \ No newline at end of file diff --git a/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs b/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs index f25a708..7128cb8 100644 --- a/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs +++ b/SubCabinetSolution/obj/Debug/MainWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "AD01C951FCD2993E0ECCB69821F7049E73D39C8DEBF507E903398E4B5AD28E05" +#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D1F125140B90CCC0F65684EA3BB9FB59D4545E918A9580741DF46EBFF6A1777A" //------------------------------------------------------------------------------ // // 此代码由工具生成。 diff --git a/SubCabinetSolution/packages.config b/SubCabinetSolution/packages.config new file mode 100644 index 0000000..e25c158 --- /dev/null +++ b/SubCabinetSolution/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file