첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
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
그리드형(광고전용)
Posted by icodebroker
,