■ GridControl 클래스의 컬럼 헤더 내에서 이미지를 표시하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Width="800" Height="600" Title="컬럼 헤더 내에서 이미지 표시하기" FontFamily="나눔고딕코딩" FontSize="16"> <Window.Resources> <DataTemplate x:Key="ProductHeaderDataTemplateKey"> <StackPanel Orientation="Horizontal"> <Image Stretch="None" Source="Product.png" /> <TextBlock Margin="5 0 0 0" Foreground="WhiteSmoke" FontWeight="Bold" Text="{Binding}" /> </StackPanel> </DataTemplate> </Window.Resources> <Grid> <dxg:GridControl x:Name="gridControl"> <dxg:GridControl.Columns> <dxg:GridColumn HeaderTemplate="{StaticResource ProductHeaderDataTemplateKey}" FieldName="ProductName"> Product </dxg:GridColumn> <dxg:GridColumn FieldName="UnitPrice"> Unit Price <dxg:GridColumn.EditSettings> <dxe:SpinEditSettings DisplayFormat="c2" MinValue="1" MaxValue="999" /> </dxg:GridColumn.EditSettings> </dxg:GridColumn> <dxg:GridColumn FieldName="OrderUnit"> Order Unit </dxg:GridColumn> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView AutoWidth="True" /> </dxg:GridControl.View> </dxg:GridControl> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); this.gridControl.ItemsSource = ProductList.GetData(); } #endregion } } |