728x90
반응형
728x170
▶ CustomColumnChooser.cs
using System.Windows;
using System.Windows.Controls;
using DevExpress.Xpf.Core;
namespace TestProject
{
/// <summary>
/// 커스텀 컬럼 선택자
/// </summary>
public class CustomColumnChooser : IColumnChooser, IColumnChooserFactory
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 커스텀 컬럼 선택자 컨트롤
/// </summary>
private readonly CustomColumnChooserControl customColumnChooserControl;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
// IColumnChooser
#region 상위 컨테이너 - TopContainer
/// <summary>
/// 상위 컨테이너
/// </summary>
public UIElement TopContainer
{
get
{
return this.customColumnChooserControl.ColunmChooserControl;
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - CustomColumnChooser(customColumnChooserControl)
/// <summary>
/// 생성자
/// </summary>
/// <param name="customColumnChooserControl">커스텀 컬럼 선택자 컨트롤</param>
public CustomColumnChooser(CustomColumnChooserControl customColumnChooserControl)
{
this.customColumnChooserControl = customColumnChooserControl;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
#region (IColumnChooserFactory) 보여주기 - Show()
/// <summary>
/// 보여주기
/// </summary>
public void Show()
{
}
#endregion
#region (IColumnChooserFactory) 숨기기 - Hide()
/// <summary>
/// 숨기기
/// </summary>
public void Hide()
{
}
#endregion
#region (IColumnChooserFactory) 상태 적용하기 - ApplyState(columnChooserState)
/// <summary>
/// 상태 적용하기
/// </summary>
/// <param name="columnChooserState">컬럼 선택자 상태</param>
public void ApplyState(IColumnChooserState columnChooserState)
{
}
#endregion
#region (IColumnChooserFactory) 상태 저장하기 - SaveState(columnChooserState)
/// <summary>
/// 상태 저장하기
/// </summary>
/// <param name="columnChooserState">컬럼 선택자 상태</param>
public void SaveState(IColumnChooserState columnChooserState)
{
}
#endregion
#region (IColumnChooserFactory) 파괴하기 - Destroy()
/// <summary>
/// 파괴하기
/// </summary>
public void Destroy()
{
}
#endregion
#region (IColumnChooserFactory) 생성하기 - Create(ownerControl)
/// <summary>
/// 생성하기
/// </summary>
/// <param name="ownerControl">오너 컨트롤</param>
/// <returns>IColumnChooser 객체</returns>
public IColumnChooser Create(Control ownerControl)
{
return this;
}
#endregion
}
}
728x90
▶ CustomColumnChooserControl.cs
using System.Windows;
using System.Windows.Controls;
using DevExpress.Xpf.Grid;
namespace TestProject
{
/// <summary>
/// 커스텀 컬럼 선택자 컨트롤
/// </summary>
public class CustomColumnChooserControl : Control
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Field
#region Field
/// <summary>
/// 뷰 속성
/// </summary>
public static readonly DependencyProperty ViewProperty =
DependencyProperty.Register("View", typeof(GridViewBase), typeof(CustomColumnChooserControl), new UIPropertyMetadata(null));
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Internal
#region 컬럼 선택자 컨트롤 - ColunmChooserControl
/// <summary>
/// 컬럼 선택자 컨트롤
/// </summary>
internal ColumnChooserControl ColunmChooserControl { get; private set; }
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 뷰 - View
/// <summary>
/// 뷰
/// </summary>
public GridViewBase View
{
get
{
return (GridViewBase)GetValue(ViewProperty);
}
set
{
SetValue(ViewProperty, value);
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - CustomColumnChooserControl()
/// <summary>
/// 생성자
/// </summary>
public CustomColumnChooserControl()
{
DefaultStyleKey = typeof(CustomColumnChooserControl);
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 템플리트 적용시 처리하기 - OnApplyTemplate()
/// <summary>
/// 템플리트 적용시 처리하기
/// </summary>
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
ColunmChooserControl = (ColumnChooserControl)GetTemplateChild("PART_ColumnChooserControl");
}
#endregion
}
}
300x250
▶ 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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:local="clr-namespace:TestProject"
Width="800"
Height="600"
Title="GridControl 클래스 : 커스텀 컬럼 선택자 생성하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Style TargetType="{x:Type local:CustomColumnChooserControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomColumnChooserControl}">
<Expander x:Name="expander"
Margin="5"
IsExpanded="{Binding ElementName=PART_ColumnChooserControl, Path=Owner.IsColumnChooserVisible}">
<ContentControl>
<Border
CornerRadius="3"
Padding="1"
Background="LightGray">
<dx:NonLogicalDecorator>
<dxg:ColumnChooserControl x:Name="PART_ColumnChooserControl"
Owner="{TemplateBinding View}"
Columns="{Binding Path=Owner.ColumnChooserColumns, RelativeSource={RelativeSource Self}}" />
</dx:NonLogicalDecorator>
</Border>
</ContentControl>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<dxg:GridControl x:Name="gridControl">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="IssueName" />
<dxg:GridColumn FieldName="IssueType" Visible="False" />
<dxg:GridColumn FieldName="IsPrivate" Visible="False" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="tableView" />
</dxg:GridControl.View>
</dxg:GridControl>
<local:CustomColumnChooserControl x:Name="customColumnChooserControl" Grid.Column="1"
Margin="10" />
</Grid>
</Window>
▶ MainWindow.xaml.cs
using System.Windows;
using DevExpress.Xpf.Grid;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.gridControl.ItemsSource = new IssueList().GetData();
InitializeCustomColumnChooserControl(this.tableView);
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 커스텀 컬럼 선택자 컨트롤 초기화 하기 - InitializeCustomColumnChooserControl(gridViewBase)
/// <summary>
/// 커스텀 컬럼 선택자 컨트롤 초기화 하기
/// </summary>
/// <param name="gridViewBase">GridViewBase 객체</param>
private void InitializeCustomColumnChooserControl(GridViewBase gridViewBase)
{
customColumnChooserControl.View = gridViewBase;
gridViewBase.ColumnChooserFactory = new CustomColumnChooser(customColumnChooserControl);
gridViewBase.ShowColumnChooser();
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'DevExpress > WPF' 카테고리의 다른 글
[DEVEXPRESS/WPF] GridControl 클래스 : MS Access 데이터베이스에 그리드 바인딩 하기 (0) | 2018.03.06 |
---|---|
[DEVEXPRESS/WPF] GridControl 클래스 : XAML 파일에 그리드 바인딩 하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 언바운드 편집 가능한 체크 컬럼 구현하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 마스터-상세 그리드 생성하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 그리드 컬럼 자동 생성하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 커스텀 컬럼 선택자 생성하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 행 선택 구현하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 커스텀 로직에 근거한 템플리트 선택하기 (0) | 2018.03.05 |
[DEVEXPRESS/WPF] GridControl 클래스 : 조건부 스타일 적용하기 (0) | 2018.03.04 |
[DEVEXPRESS/WPF] GridControl 클래스 : 포커스 데이터 행과 포커스 셀의 모양 변경하기 (0) | 2018.03.04 |
[DEVEXPRESS/WPF] TreeListControl 클래스 : 수동으로 드래그 & 드롭 사용하기 (0) | 2018.03.04 |
댓글을 달아 주세요