[C#/WPF/DEVEXPRESS] GridControl 클래스 : 그리드 컬럼에서 스파크 라인 보여주기
■ 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 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="800" Height="600" Title="그리드 컬럼에서 스파크 라인 보여주기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"> <dxg:GridControl x:Name="gridControl" ItemsSource="{Binding SaleDataRowList}"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="Title" Header="Order" ReadOnly="True" Width="200" /> <dxg:GridColumn FieldName="SparklineData" Header="Sales" Width="200"> <dxg:GridColumn.EditSettings> <dxe:SparklineEditSettings PointArgumentMember="ArgumentColumn" PointValueMember="ValueColumn"> <dxe:SparklineEditSettings.PointArgumentRange> <dxe:Range Auto="False" Limit1="07/17/2013" Limit2="08/15/2013" /> </dxe:SparklineEditSettings.PointArgumentRange> <dxe:SparklineEditSettings.StyleSettings> <dxe:AreaSparklineStyleSettings Brush="BlueViolet" HighlightMaxPoint="True" HighlightMinPoint="True" MaxPointBrush="Red" MinPointBrush="Blue" /> </dxe:SparklineEditSettings.StyleSettings> </dxe:SparklineEditSettings> </dxg:GridColumn.EditSettings> </dxg:GridColumn> </dxg:GridControl.Columns> </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 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// 난수 발생기 /// </summary> private Random random = new Random(); #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 판매 데이터 행 리스트 - SaleDataRowList /// <summary> /// 판매 데이터 행 리스트 /// </summary> public List<SaleDataRow> SaleDataRowList { get; set; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); this.gridControl.DataContext = this; SaleDataRowList = new List<SaleDataRow>(); int rowCount = 20; for(int i = 0; i < rowCount; i++) { SaleDataRowList.Add ( new SaleDataRow() { Title = string.Format("Index : {0}", i + 1), SparklineData = CreateSparklineData() } ); } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 스파크 라인 데이터 생성하기 - CreateSparklineData() /// <summary> /// 스파크 라인 데이터 생성하기 /// </summary> /// <returns>스파크 라인 데이터</returns> private IList CreateSparklineData() { ObservableCollection<SaleItem> saleItemCollection = new ObservableCollection<SaleItem>(); DateTime dateTime = new DateTime(2013, 07, 17); for(int i = 0; i < 30; i++) { saleItemCollection.Add ( new SaleItem() { ValueColumn = random.Next(-20, 20), ArgumentColumn = dateTime.AddDays(i) } ); } return saleItemCollection; } #endregion } } |
TestProject.zip