첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ IntegerToBinaryOperatorValueConverter.cs

using System;
using System.Globalization;
using System.Windows.Data;

using DevExpress.Data.Filtering;

namespace TestProject
{
    /// <summary>
    /// 정수↔바이너리 연산자 값 변환자
    /// </summary>
    public class IntegerToBinaryOperatorValueConverter : IValueConverter
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 변환하기 - Convert(value, targetType, parameter, cultureInfo)

        /// <summary>
        /// 변환하기
        /// </summary>
        /// <param name="value">값</param>
        /// <param name="targetType">타겟 타입</param>
        /// <param name="parameter">매개 변수</param>
        /// <param name="cultureInfo">CultureInfo 객체</param>
        /// <returns>변환 값</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo)
        {
            BinaryOperator binaryOperator = value as BinaryOperator;

            if(object.ReferenceEquals(binaryOperator, null))
            {
                return null;
            }

            OperandValue operandValue = binaryOperator.RightOperand as OperandValue;

            return operandValue.Value;
        }

        #endregion
        #region 역변환하기 - ConvertBack(value, targetType, parameter, cultureInfo)

        /// <summary>
        /// 역변환하기
        /// </summary>
        /// <param name="value">값</param>
        /// <param name="targetType">타겟 타입</param>
        /// <param name="parameter">매개 변수</param>
        /// <param name="cultureInfo">CultureInfo 객체</param>
        /// <returns>역변환 값</returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cultureInfo)
        {
            return new BinaryOperator("Index", System.Convert.ToInt32(value), BinaryOperatorType.Greater);
        }

        #endregion
    }
}

 

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    xmlns:local="clr-namespace:TestProject"
    Width="800"
    Height="600"
    Title="커스텀 필터 드롭 다운 생성하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Grid.Resources>
            <local:IntegerToBinaryOperatorValueConverter x:Key="IntegerToBinaryOperatorValueConverterKey" />
        </Grid.Resources>
        <dxg:GridControl x:Name="gridControl">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="Index" FilterPopupMode="Custom">
                    <dxg:GridColumn.CustomColumnFilterPopupTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Label Margin="5" Content="Minimum Index :" />
                                    <Slider
                                        Margin="5"
                                        Width="200"
                                        Minimum="1"
                                        Maximum="99"
                                        Value="{Binding Path=CustomColumnFilter, RelativeSource={RelativeSource TemplatedParent},
                                            Converter={StaticResource IntegerToBinaryOperatorValueConverterKey}}" />
                            </StackPanel>
                        </DataTemplate>
                    </dxg:GridColumn.CustomColumnFilterPopupTemplate>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

 

▶ MainWindow.xaml.cs

using System.Windows;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.gridControl.ItemsSource = new SampleList().GetData();
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요