728x90
반응형
728x170
▶ MainViewModel.cs
using System;
using System.Windows.Input;
using DevExpress.Xpf.Mvvm;
namespace HowToManageDocumentsViaCurrentWindowService
{
/// <summary>
/// 메인 뷰 모델
/// </summary>
public class MainViewModel : ViewModelBase
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Close Window 명령 - CloseWindowCommand
/// <summary>
/// Close Window 명령
/// </summary>
public ICommand CloseWindowCommand { get; private set; }
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 현재 윈도우 서비스 - CurrentWindowService
/// <summary>
/// 현재 윈도우 서비스
/// </summary>
private ICurrentWindowService CurrentWindowService
{
get
{
return ServiceContainer.GetService<ICurrentWindowService>();
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainViewModel()
/// <summary>
/// 생성자
/// </summary>
public MainViewModel()
{
CloseWindowCommand = new DelegateCommand(OnCloseWindowCommandExecute);
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Close Window 명령 실행시 처리하기 - OnCloseWindowCommandExecute()
/// <summary>
/// Close Window 명령 실행시 처리하기
/// </summary>
private void OnCloseWindowCommandExecute()
{
CurrentWindowService.Close();
}
#endregion
}
}
728x90
▶ MainView.xaml
<UserControl
x:Class="HowToManageDocumentsViaCurrentWindowService.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:HowToManageDocumentsViaCurrentWindowService">
<UserControl.DataContext>
<local:MainViewModel />
</UserControl.DataContext>
<dxm:Interaction.Behaviors>
<dxm:CurrentWindowService Window="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
</dxm:Interaction.Behaviors>
<Grid>
<Button
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="5"
FontSize="16"
Content="Close Window"
Command="{Binding CloseWindowCommand}" />
</Grid>
</UserControl>
300x250
▶ MainWindow.xaml
<Window
x:Class="HowToManageDocumentsViaCurrentWindowService.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HowToManageDocumentsViaCurrentWindowService"
Title="CurrentWindowService"
Width="600"
Height="450">
<Grid>
<local:MainView />
</Grid>
</Window>
728x90
반응형
그리드형(광고전용)
'DevExpress > WPF' 카테고리의 다른 글
[DEVEXPRESS/WPF] BaseColumn 클래스 : HeaderTemplate 속성을 컬럼 헤더를 정의하는 DataTemplate 설정하기 (0) | 2014.03.14 |
---|---|
[DEVEXPRESS/WPF] GridColumn 엘리먼트 : EditSettings 속성을 사용해 SpinEditSettings 설정하기 (0) | 2014.03.14 |
[DEVEXPRESS/WPF] GridControl 엘리먼트 사용하기 (0) | 2014.03.14 |
[DEVEXPRESS/WPF] WindowedDocumentUIService 엘리먼트 사용하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] TabbedDocumentUIService 엘리먼트 사용하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] LayoutPanel 엘리먼트 사용하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] DockLayoutManager 엘리먼트 사용하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] TextEdit 엘리먼트 : 2개 이상의 줄 입력하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] DateEdit 엘리먼트 : AllowSpinOnMouseWheel 속성 사용하기 (0) | 2014.03.13 |
[DEVEXPRESS/WPF] SpinEdit 엘리먼트 : DisplayFormatString 속성을 사용해 과학적 표기법 포맷 설정하기 (0) | 2014.03.13 |
댓글을 달아 주세요