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

TestProject.zip
다운로드

▶ IntegerToBooleanValueConverter.cs

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

namespace TestProject
{
    /// <summary>
    /// 정수→진리값 값 변환자
    /// </summary>
    [ValueConversion(typeof(object), typeof(bool))]
    public class IntegerToBooleanValueConverter : 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)
        {
            int count = (int)(value);

            return count > 0;
        }

        #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 null;
        }

        #endregion
    }
}

 

728x90

 

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestProject"
    Width="800"
    Height="600"
    Title="상세 확장 버튼 표시 조정하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <local:IntegerToBooleanValueConverter x:Key="IntegerToBooleanValueConverterKey" />
    </Window.Resources>
    <Grid>
        <dxg:GridControl x:Name="gridControl"
            AutoPopulateColumns="True">
            <dxg:GridControl.DetailDescriptor>
                <dxg:DataControlDetailDescriptor ItemsSourcePath="ProductList">
                    <dxg:DataControlDetailDescriptor.DataControl>
                        <dxg:GridControl AutoPopulateColumns="True">
                            <dxg:GridControl.View>
                                <dxg:TableView ShowGroupPanel="False" />
                            </dxg:GridControl.View>
                        </dxg:GridControl>
                    </dxg:DataControlDetailDescriptor.DataControl>
                </dxg:DataControlDetailDescriptor>
            </dxg:GridControl.DetailDescriptor>
            <dxg:GridControl.View>
                <dxg:TableView
                    ShowGroupPanel="False"
                    IsDetailButtonVisibleBinding="{Binding Row.ProductList.Count, Converter={StaticResource IntegerToBooleanValueConverterKey}}" />
            </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 DataSource().CategoryList;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요