[DEVEXPRESS/WPF] EventToCommand 엘리먼트 : ProcessNewValue 이벤트 발생시 명령 실행하기
DevExpress/WPF 2014. 3. 31. 09:00728x90
728x170
▶ ProductNameEventArgsConverter.cs
using DevExpress.Xpf.Editors;
using DevExpress.Xpf.Mvvm.UI;
/// <summary>
/// 제품명 이벤트 인자 변환자
/// </summary>
public class ProductNameEventArgsConverter : IEventArgsConverter
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 변환하기 - Convert(e)
/// <summary>
/// 변환하기
/// </summary>
/// <param name="e">이벤트 인자</param>
/// <returns>변환 값</returns>
public object Convert(object e)
{
string productName = (e as ProcessNewValueEventArgs).DisplayText;
return productName;
}
#endregion
}
728x90
▶ ProductListViewModel.cs
/// <summary>
/// 제품 리스트 뷰 모델
/// </summary>
public class ProductListViewModel : ViewModelBase
{
...
/// <summary>
/// 제품 폼 보여주기 명령
/// </summary>
private ICommand showProductFormCommand;
...
#region 제품 폼 보여주기 명령 - ShowProductFormCommand
/// <summary>
/// 제품 폼 보여주기 명령
/// </summary>
public ICommand ShowProductFormCommand
{
get
{
if(this.showProductFormCommand == null)
{
this.showProductFormCommand = new DelegateCommand<string>(OnShowProductFormCommandExecute);
}
return this.showProductFormCommand;
}
}
#endregion
...
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 제품 폼 보여주기 명령 실행시 처리하기 - OnShowProductFormCommandExecute(parameter)
/// <summary>
/// 제품 폼 보여주기 명령 실행시 처리하기
/// </summary>
/// <param name="parameter">매개 변수</param>
private void OnShowProductFormCommandExecute(string parameter)
{
if(string.IsNullOrEmpty(parameter))
{
return;
}
...
}
#endregion
}
300x250
▶ MainWindow.xaml
<Window
x:Class="HowToProcessNewValuesInLookUpEdit.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:HowToProcessNewValuesInLookUpEdit"
Title="Process New Values in LookUpEdit"
Width="600"
Height="450">
<Window.DataContext>
<local:ProductListViewModel />
</Window.DataContext>
<Grid>
<dxg:LookUpEdit x:Name="lookUpEdit"
ItemsSource="{Binding Path=ProductCollection}"
Width="200"
Height="25"
ValueMember="ID"
DisplayMember="ProductName"
AddNewButtonPlacement="EditBox"
AutoComplete="True"
IncrementalFiltering="True"
ImmediatePopup="True"
AutoPopulateColumns="True"
IsPopupAutoWidth="False">
<dxmvvm:Interaction.Triggers>
<dxmvvm:EventToCommand
PassEventArgsToCommand="True"
Command="{Binding ShowProductFormCommand}"
EventName="ProcessNewValue"
SourceName="lookUpEdit">
<dxmvvm:EventToCommand.EventArgsConverter>
<local:ProductNameEventArgsConverter />
</dxmvvm:EventToCommand.EventArgsConverter>
</dxmvvm:EventToCommand>
</dxmvvm:Interaction.Triggers>
</dxg:LookUpEdit>
</Grid>
</Window>
728x90
그리드형(광고전용)
'DevExpress > WPF' 카테고리의 다른 글
[DEVEXPRESS/WPF] BarButtonItem 엘리먼트 : KeyGesture 속성 사용하기 (0) | 2014.04.15 |
---|---|
[DEVEXPRESS/WPF] BarButtonItem 엘리먼트 : Command 속성 사용하기 (0) | 2014.04.15 |
[DEVEXPRESS/WPF] InsertMainMenuIfNotExistAction 엘리먼트 사용하기 (0) | 2014.04.14 |
[DEVEXPRESS/WPF] RemoveBarItemAndLinkAction 엘리먼트 사용하기 (0) | 2014.04.14 |
[DEVEXPRESS/WPF] BarManagerActionContainer 엘리먼트 사용하기 (0) | 2014.04.14 |
[DEVEXPRESS/WPF] DialogService 엘리먼트 : 대화 상자 보여주기 (0) | 2014.03.31 |
[DEVEXPRESS/WPF] GroupFrame 엘리먼트 사용하기 (0) | 2014.03.31 |
[DEVEXPRESS/WPF] ToolbarListItem 엘리먼트 사용하기 (0) | 2014.03.31 |
[DEVEXPRESS/WPF] BarLinkContainerItem 엘리먼트 사용하기 (0) | 2014.03.31 |
[DEVEXPRESS/WPF] BarEditItem 엘리먼트 : 스핀 에디터 사용하기 (0) | 2014.03.31 |