私は WPF ウィンドウを持っています。datacontext は XAML を使用してインスタンス化されます
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ViewModels="clr-namespace:Contratos.ViewModels" x:Class="Contratos.Views.TipoAsociadoAcopio"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
xmlns:l="clr-namespace:Recursos;assembly=Recursos"
xmlns:controls="clr-namespace:Recursos.Controls;assembly=Recursos"
xmlns:resources="clr-namespace:ModelSeguridad.Resources;assembly=ModelSeguridad"
Title="{x:Static resources:Labels.CONTRATO_TipoContratoAcopio}" Height="Auto" Width="Auto">
<Window.Resources>
<CollectionViewSource x:Key="ListaItems" Source="{Binding ListaItems}"/>
<ViewModels:TipoAsociadoVM x:Key="ViewDataContext"/>
</Window.Resources>
<Grid>
<StackPanel>
<Button Command="{Binding _ICommandExit}" CommandParameter="{W H A T H E R E}" />
</StackPanel>
</Grid>
ユーザーが [終了] ボタンをクリックしたときに、このウィンドウを閉じる必要があります。私の質問は、XAML を使用してインスタンス化された場合、ウィンドウ参照をビューモデルに送信するにはどうすればよいかです。
私はMVVMパターンを維持しようとしています。これは、コードビハインドにコードがないためです。