Data Access has been discontinued. Please refer to this page for more information.

Setting up the Main View

In this step you will set up the main view which will be the entry point of the application. Through this view you will be able to view, filter and delete cars from the database. To set up the view you will need to create an interface defining the views functionality, create a WPF Window and implement the defined interface.

Defining the main view`s interface

  1. In the ViewInterfaces folder add a new Interface with name IMainView. This interface derives from IView and defines the specific functionality of the main view for the application which is the ability to display it through the Show() method.

    public interface IMainView : IView
    {
        void Show();
    }
    
    Public Interface IMainView
        Inherits IView
        Sub Show()
    End Interface
    

Setting up the window

  1. The default window of the WPF project MainWindow will act as the main view and entry point of the application. Move it to the Views folder.
  2. In the XAML View of MainWindow, set its local namespace in the opening Window tag to:

    xmlns:local ="clr-namespace:SofiaCarRental.WPF.Views" 
    
    xmlns:local ="clr-namespace:SofiaCarRental.WPF"
    
  3. Implement the IMainView interface in the code behid of MainWindow in order to expose the defined functionality.

    public partial class MainWindow : Window, IMainView
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
    
    Public Class MainWindow
        Inherits Window
        Implements IMainView
        Public Sub New()
            InitializeComponent()
        End Sub
        Public Overloads Property DataContext As Object Implements IView.DataContext
            Get
                Return MyBase.DataContext
            End Get
            Set(ByVal value As Object)
                MyBase.DataContext = value
            End Set
        End Property
        Public Overloads Sub Show() Implements IMainView.Show
            MyBase.Show()
        End Sub
        Public Overloads Sub Close() Implements IView.Close
            MyBase.Close()
        End Sub
    End Class
    

Next step: Setting up the Secondary View