첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

▶ 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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:local="clr-namespace:HowToProcessNewValuesInLookUpEdit">

    ...

    <dxmvvm:Interaction.Behaviors>
        <dx:DialogService DialogWindowStartupLocation="CenterOwner">
            <dx:DialogService.ViewTemplate>
                <DataTemplate>
                    <local:ProductControl />
                </DataTemplate>
            </dx:DialogService.ViewTemplate>
            <dx:DialogService.DialogStyle>
                <Style TargetType="dx:DXDialogWindow">
                    <Setter Property="Width"  Value="340" />
                    <Setter Property="Height" Value="340" />
                </Style>
            </dx:DialogService.DialogStyle>
        </dx:DialogService>
    </dxmvvm:Interaction.Behaviors>
</Window>

 

728x90

 

▶ C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;

using DevExpress.Xpf.Mvvm;

/// <summary>
/// 제품 리스트 뷰 모델
/// </summary>
public class ProductListViewModel : ViewModelBase 
{
    ...

    #region 대화 상자 서비스 - DialogService

    /// <summary>
    /// 대화 상자 서비스
    /// </summary>
    public IDialogService DialogService
    {
        get
        {
            return GetService<IDialogService>();
        }
    }

    #endregion

    ...

    Product product = new Product() { ProductName = strParameter };

    UICommand addProductUICommand = new UICommand()
    {
        Caption   = "Add",
        IsCancel  = false,
        IsDefault = true
    };

    UICommand cancelProductUICommand = new UICommand()
    {
        Caption   = "Cancel",
        IsDefault = false,
        IsCancel  = true
    };

    UICommand resultUICommand = DialogService.ShowDialog(new List<UICommand>() { addProductUICommand, cancelProductUICommand}, "Add New Product", product);

    if(resultUICommand == addProductUICommand)
    {
        this.productCollection.Add(product);
    }

    ...
}

※ ProductControl는 UserControl을 상속받은 클래스이다.

※ Product는 모델 클래스이다.

728x90
그리드형(광고전용)
Posted by icodebroker
,