Installing Archives - Mvvmlight Blog about accelerating the creation and development of MVVM applications Mon, 17 Jun 2024 07:51:25 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.4 https://www.mvvmlight.net/wp-content/uploads/2024/06/cropped-laptop-1626471_640-32x32.png Installing Archives - Mvvmlight 32 32 Adding MVVM Light with NuGet https://www.mvvmlight.net/installing/nuget/ Thu, 17 Aug 2023 07:46:00 +0000 https://www.mvvmlight.net/?p=28 NuGet is a package manager that allows you to add packages (such as assemblies and source code) to an existing project.

The post Adding MVVM Light with NuGet appeared first on Mvvmlight.

]]>
What is NuGet?

NuGet is a package manager that allows you to add packages (such as assemblies and source code) to an existing project. All versions of MVVM Light are supported through NuGet. To learn more and install NuGet, visit nuget.org.

Finding and Installing MVVM Light with NuGet

To add MVVM Light to your project using NuGet, follow these steps:

  1. Open your project in Visual Studio.
  2. Right-click on the References folder and select Manage NuGet Packages… from the context menu.Note: If this option is missing, you need to install the NuGet package manager from nuget.org.
  3. In the Manage NuGet Packages dialog, select Online on the right.
  4. Enter “mvvmlight” in the search field.
  5. Select the MVVM Light package and click the Install button (choose the top option for the full package).

Changes to Your Project

After installation, the following changes will be made to your project:

  • A packages folder will be added containing the necessary libraries. This folder is added to the root of the project structure but does not appear in the Solution Explorer.
  • A ViewModel folder will be added with two classes:
    • ViewModelLocator.cs
    • MainViewModel.cs
  • The App.xaml file will be modified to include the ViewModelLocator as a global resource.

Binding the DataContext in XAML

With the new file structure, the ViewModelLocator is exposed in App.xaml (global resources) and can be used as the source of the DataContext bindings. The MainViewModel added to the project is exposed in the ViewModelLocator as a property. For more details on this architecture, refer to Understanding the MVVM Pattern and Deep Dive MVVM.

Note: If you don’t need MainViewModel in your project, you can remove this class.

To use MainViewModel as the DataContext of the MainPage or MainWindow, follow these steps:

  1. Open MainPage.xaml or MainWindow.xaml.
  2. Add the following line to the opening tag of MainPage/MainWindow:xml

Binding the DataContext in Blend

You can also bind the DataContext visually in Blend:

  1. Open your project in Blend.
  2. Build the application.
  3. Open MainPage/MainWindow.
  4. In the Objects and Timeline panel, select the top element (Window, Page, etc.).
  5. In the Properties panel, select the DataContext property (in the Common Properties section).
  6. Click the small advanced options peg next to the property field and select Data Binding from the context menu.
  7. In the Data Binding editor, select the Data Field tab and the Locator data source. Note: If you don’t see the Locator field, you need to build the project.
  8. In the Fields area, expand ViewModelLocator and select the Main property. Click OK to close the Data Binding editor.

Installing Without the ViewModel Folder (Libraries Only)

If you’re adding MVVM Light to an existing application with an existing ViewModelLocator and/or viewmodels, you should install the “libraries only” NuGet package. Follow the steps above, but select MVVM Light libraries only instead of the full MVVM Light package.

Installing Portable Class Libraries

To install the portable class libraries (PCL) version of MVVM Light, follow the steps above and select MVVM Light libraries only (PCL).

The post Adding MVVM Light with NuGet appeared first on Mvvmlight.

]]>
Installing the MVVM Light Toolkit https://www.mvvmlight.net/installing/ Wed, 12 Jul 2023 07:43:00 +0000 https://www.mvvmlight.net/?p=25 To add MVVM Light to an existing project, use the NuGet package manager. This is the recommended method for downloading and integrating MVVM Light.

The post Installing the MVVM Light Toolkit appeared first on Mvvmlight.

]]>
Adding MVVM Light to an Existing Project

To add MVVM Light to an existing project, use the NuGet package manager. This is the recommended method for downloading and integrating MVVM Light.

Getting the Source Code

If you’re interested, you can access the source code for MVVM Light. This is optional. MVVM Light is an open-source project licensed under the MIT License.

Cleaning Up Before Installation

Due to its long history, MVVM Light may have installed files in various locations. To avoid potential issues, it is advisable to clean up old files if you have previously installed older versions manually. You can download a cleanup application and follow the instructions on the “Cleaning” page to assist with this process.

Installation Instructions

The easiest way to install MVVM Light in Visual Studio 2012 and 2013 is through the Extensions and Updates gallery:

  1. Start Visual Studio 2012 or 2013.
  2. Select Tools > Extensions and Updates.
  3. In the Extensions and Updates dialog, select Online on the left-hand side.
  4. Enter “mvvm light” in the search field.
  5. Click the Download button.
  6. Wait for the download to complete.
  7. Accept the license agreement.
  8. Click the Restart button.

Once MVVM Light is installed, you can go to File > New Project and find the MVVM Light project templates ready for use. Additionally, if you place the cursor in your code and type “mvvm”, you will see available code snippets.

Visual Studio 2010

Currently, there is no full installer support for Visual Studio 2010. For now, please use NuGet to add MVVM Light to your application in Visual Studio 2010.

The post Installing the MVVM Light Toolkit appeared first on Mvvmlight.

]]>
Creating a new MVVM Light application in Visual Studio https://www.mvvmlight.net/creating/ Fri, 07 Jul 2023 07:40:00 +0000 https://www.mvvmlight.net/?p=22 If you're starting a new project, you can easily create a new MVVM Light project in Visual Studio. The MVVM Light Toolkit provides a project template for each supported XAML framework

The post Creating a new MVVM Light application in Visual Studio appeared first on Mvvmlight.

]]>
Installing the MVVM Light Toolkit

For detailed installation instructions, please refer to post.

Creating a New MVVM Light Project

If you’re starting a new project, you can easily create a new MVVM Light project in Visual Studio. The MVVM Light Toolkit provides a project template for each supported XAML framework, including WPF, Silverlight, Windows Phone, and Windows 8.

  1. In Visual Studio, go to the menu and select File > New > Project.
  2. In the New Project dialog, choose one of the following categories:
    • Windows Store (Windows 8)
    • Windows (WPF)
    • Silverlight
    • Windows Phone
    You can also find all templates directly under the Visual C# category.

Executing the Application

To run the sample application:

  1. Press Ctrl+F5 in Visual Studio.
  2. The appropriate environment will start, and the application will be displayed.

The post Creating a new MVVM Light application in Visual Studio appeared first on Mvvmlight.

]]>
Documentation https://www.mvvmlight.net/doc/ Tue, 20 Jun 2023 07:32:00 +0000 https://www.mvvmlight.net/?p=19 A Pluralsight course titled MVVM Light Toolkit Fundamentals is now available! This is the ideal starting point to dive into the toolkit.

The post Documentation appeared first on Mvvmlight.

]]>
A Pluralsight course titled MVVM Light Toolkit Fundamentals is now available! This is the ideal starting point to dive into the toolkit.

The course offers a comprehensive overview of each component within the MVVM Light Toolkit, supplemented with numerous examples. The entire course comprises six modules, totaling 4 hours and 30 minutes of instructional content.

  1. Module 1: Introduction to MVVM
  2. Module 2: Refactoring the App to MVVM
  3. Module 3: The Core Components
  4. Module 4: The Extras
  5. Module 5: Installing MVVM Light and Additional Components
  6. Module 6: Advanced Examples With MVVM Light

Xamarin

For Xamarin, check out my talk at Xamarin Evolve along with the related sample project.

Navigation Service

The process of initializing and using the MVVM Light NavigationService varies depending on the platform. This series of articles details how to do so across all supported platforms:

  • The INavigationService interface
  • Xamarin.iOS (with Storyboards)
  • Xamarin.iOS (with XIB)
  • Xamarin.Android
  • Windows Store (WinRT) (coming soon)
  • Windows Phone Applications (WinRT) (coming soon)
  • Windows Phone Silverlight (coming soon)
  • Xamarin.Forms (coming soon)
  • Windows Presentation Foundation (coming soon)
  • Silverlight (coming soon)

Blog Posts

My blog features a dedicated category for all MVVM Light-related announcements.

Source Code Documentation

The source code documentation is available in CHM (Compiled HTML) format and as a website. For more details, please visit this page.

The post Documentation appeared first on Mvvmlight.

]]>