markus / KCOM / Behaviors / GridViewAutoWidthBehavior.cs @ cc3d8471
이력 | 보기 | 이력해설 | 다운로드 (2.04 KB)
1 | fad4d1c0 | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Linq.Expressions; |
||
5 | using System.Reflection; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | using System.Windows; |
||
9 | 84190963 | taeseongkim | using System.Windows.Data; |
10 | fad4d1c0 | taeseongkim | using System.Windows.Media; |
11 | using System.Windows.Shapes; |
||
12 | using Telerik.Windows.Controls; |
||
13 | |||
14 | namespace KCOM.Behaviors |
||
15 | { |
||
16 | 84190963 | taeseongkim | public class GridViewAutoWidthBehavior |
17 | fad4d1c0 | taeseongkim | { |
18 | 84190963 | taeseongkim | private readonly RadGridView gridView = null; |
19 | |||
20 | public static bool GetIsEnabled(DependencyObject obj) |
||
21 | fad4d1c0 | taeseongkim | { |
22 | 84190963 | taeseongkim | return (bool)obj.GetValue(IsEnabledProperty); |
23 | fad4d1c0 | taeseongkim | } |
24 | |||
25 | 84190963 | taeseongkim | public static void SetIsEnabled(DependencyObject obj, bool value) |
26 | fad4d1c0 | taeseongkim | { |
27 | 84190963 | taeseongkim | obj.SetValue(IsEnabledProperty, value); |
28 | fad4d1c0 | taeseongkim | } |
29 | |||
30 | 84190963 | taeseongkim | // Using a DependencyProperty as the backing store for IsEnabled. This enables animation, styling, binding, etc... |
31 | public static readonly DependencyProperty IsEnabledProperty = |
||
32 | DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(GridViewAutoWidthBehavior), new PropertyMetadata(false, OnIsEnabledChanged)); |
||
33 | |||
34 | private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||
35 | fad4d1c0 | taeseongkim | { |
36 | 84190963 | taeseongkim | RadGridView grid = d as RadGridView; |
37 | fad4d1c0 | taeseongkim | |
38 | 84190963 | taeseongkim | if (grid != null) |
39 | { |
||
40 | var behavior = new GridViewAutoWidthBehavior(grid); |
||
41 | } |
||
42 | } |
||
43 | fad4d1c0 | taeseongkim | |
44 | 84190963 | taeseongkim | public GridViewAutoWidthBehavior(RadGridView grid) |
45 | { |
||
46 | this.gridView = grid; |
||
47 | if (this.gridView != null) |
||
48 | fad4d1c0 | taeseongkim | { |
49 | 84190963 | taeseongkim | this.gridView.LoadingRowDetails += new EventHandler<Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs>(OnLoadingRowDetails); |
50 | fad4d1c0 | taeseongkim | } |
51 | } |
||
52 | 84190963 | taeseongkim | |
53 | void OnLoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e) |
||
54 | { |
||
55 | var widthProxy = new WidthProxy(); |
||
56 | widthProxy.TargetElement = e.DetailsElement; |
||
57 | widthProxy.SetBinding(WidthProxy.WidthProperty, new Binding("ActualWidth") { Source = sender as RadGridView }); |
||
58 | } |
||
59 | |||
60 | fad4d1c0 | taeseongkim | } |
61 | } |