첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

▶ Employee.cs

using System.ComponentModel.DataAnnotations;

namespace TestProject
{
    /// <summary>
    /// 직원
    /// </summary>
    public class Employee
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region ID - ID

        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }

        #endregion

        #region 상급자 ID - ParentID

        /// <summary>
        /// 상급자 ID
        /// </summary>
        public int ParentID { get; set; }

        #endregion

        #region 성명 - Name

        /// <summary>
        /// 성명
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "The Name cannot be empty. Please correct.")]
        public string Name { get; set; }

        #endregion

        #region 직위 - Position

        /// <summary>
        /// 직위
        /// </summary>
        [StringLength(20)]
        public string Position { get; set; }

        #endregion

        #region 부서 - Department

        /// <summary>
        /// 부서
        /// </summary>
        [Required(AllowEmptyStrings = false, ErrorMessage = "The Department cannot be empty. Please correct.")]
        public string Department { get; set; }

        #endregion
    }
}

 

▶ MainPage.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"
    Width="600"
    Height="450"
    Title="어트리뷰트 기반 검증하기">
    <Grid>
        <dxg:GridControl Name="gridControl" >
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="Name"       />
                <dxg:GridColumn FieldName="Position"   />
                <dxg:GridColumn FieldName="Department" />
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView Name="tableView"
                    ShowValidationAttributeErrors="True"
                    AllowCommitOnValidationAttributeError="False" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

 

728x90
반응형
Posted by 사용자 icodebroker

댓글을 달아 주세요