# Adding New View-ViewModel for Package Info
1. Create XAML view code
```xml
```
2. Create C# ViewModel Class
```cs
using MitechLib.Infrastructure.Data;
namespace MitechLib.Modules.PackagePage.ViewModels
{
public class CarrierInfoViewModel : ViewModelBase
{
private string _labelPitchX;
public string LabelPitchX
{
get { return _labelPitchX; }
set { _labelPitchX = value; }
}
public CarrierInfoViewModel()
{
LabelPitchX = "Pitch X (mm)";
}
}
}
```
3. Decorate the MEF `[Export] / [Import]` attributes
```cs
using MitechLib.Infrastructure.Data;
using System.ComponentModel.Composition;
namespace MitechLib.Modules.PackagePage.ViewModels
{
[Export]
public class CarrierInfoViewModel : ViewModelBase
{
private string _labelPitchX;
public string LabelPitchX
{
get { return _labelPitchX; }
set { _labelPitchX = value; }
}
public CarrierInfoViewModel()
{
LabelPitchX = "Pitch X-- (mm)";
}
}
}
```
```cs
using Microsoft.Practices.Prism.Regions;
using System.ComponentModel.Composition;
using System.Windows.Controls;
namespace MitechLib.Modules.PackagePage.Views
{
///
/// Interaction logic for CarrierInfoView.xaml
///
[ViewSortHint("02")]
[PartCreationPolicy(CreationPolicy.Shared)]
[Export]
public partial class CarrierInfoView : UserControl
{
public CarrierInfoView()
{
InitializeComponent();
}
}
}
```
4. Setup DataContext Binding
```cs
using Microsoft.Practices.Prism.Regions;
using MitechLib.Modules.PackagePage.ViewModels;
using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Controls;
namespace MitechLib.Modules.PackagePage.Views
{
///
/// Interaction logic for CarrierInfoView.xaml
///
[ViewSortHint("02")]
[PartCreationPolicy(CreationPolicy.Shared)]
[Export]
public partial class CarrierInfoView : UserControl
{
public CarrierInfoView()
{
InitializeComponent();
}
[Import]
[SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly",
Justification = "Needs to be a property to be composed by MEF")]
public CarrierInfoViewModel ViewModel
{
set
{
this.DataContext = value;
}
}
}
}
```
```xml
...
..
```
5. Integration with Mitech view registration by updating the `ModuleViewNames.cs` related dictionary with `MitechLib.InfrastructureModules`
```cs
public static readonly Dictionary DeviceInfoRegion = new Dictionary
{
{"CassetteInfoView", "MitechLib.Modules.PackagePage.Views.CassetteInfoView"},
{"VisionSettingView", "MitechLib.Modules.PackagePage.Views.VisionSettingView"},
//
{"CarrierInfoView", "MitechLib.Modules.PackagePage.Views.CarrierInfoView"}
};
```