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
-
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
- 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.
-
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"
-
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