Public Class ExecuteWindowV #Region "FIELDS & PROPERTIES" Private WithEvents m_ExecuteWindowVM As ExecuteWindowVM #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(Owner As Window, ExecuteWindowVM As ExecuteWindowVM) MyBase.New(Owner) ' This call is required by the designer. InitializeComponent() Me.DataContext = ExecuteWindowVM ' Assegno al riferimento locale al VM il VM preso dal DataContext m_ExecuteWindowVM = ExecuteWindowVM End Sub #End Region ' Constructor Private Sub CloseWindow(bDialogResult As Boolean) Handles m_ExecuteWindowVM.m_CloseWindow Me.DialogResult = bDialogResult End Sub Private Sub EgtCustomWindow_PreviewKeyDown(sender As Object, e As KeyEventArgs) If e.Key = Key.Escape Then Me.Close() End If End Sub End Class