markus / ConvertService / ServiceBase / Markus.Service.StationController / Controls / RowIndexColumn.cs @ 6b24246c
이력 | 보기 | 이력해설 | 다운로드 (1.42 KB)
1 | a34f58f6 | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | using System.Windows; |
||
7 | using System.Windows.Controls; |
||
8 | |||
9 | namespace Markus.Service.StationController.Controls |
||
10 | { |
||
11 | public class RowIndexColumn : Telerik.Windows.Controls.GridViewColumn |
||
12 | { |
||
13 | public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem) |
||
14 | { |
||
15 | TextBlock textBlock = cell.Content as TextBlock; |
||
16 | |||
17 | if (textBlock == null) |
||
18 | { |
||
19 | textBlock = new TextBlock(); |
||
20 | } |
||
21 | |||
22 | textBlock.Text = string.Format("{0}", this.DataControl.Items.IndexOf(dataItem) + 1); |
||
23 | |||
24 | return textBlock; |
||
25 | } |
||
26 | |||
27 | protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args) |
||
28 | { |
||
29 | base.OnPropertyChanged(args); |
||
30 | |||
31 | if (args.PropertyName == "DataControl") |
||
32 | { |
||
33 | if (this.DataControl != null && this.DataControl.Items != null) |
||
34 | { |
||
35 | this.DataControl.Items.CollectionChanged += (s, e) => |
||
36 | { |
||
37 | if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) |
||
38 | { |
||
39 | this.Refresh(); |
||
40 | } |
||
41 | }; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | } |