프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Behaviors / GridViewAutoWidthBehavior.cs @ 84190963

이력 | 보기 | 이력해설 | 다운로드 (2.04 KB)

1
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
using System.Windows.Data;
10
using System.Windows.Media;
11
using System.Windows.Shapes;
12
using Telerik.Windows.Controls;
13

    
14
namespace KCOM.Behaviors
15
{
16
    public class GridViewAutoWidthBehavior
17
    {
18
        private readonly RadGridView gridView = null;
19

    
20
        public static bool GetIsEnabled(DependencyObject obj)
21
        {
22
            return (bool)obj.GetValue(IsEnabledProperty);
23
        }
24

    
25
        public static void SetIsEnabled(DependencyObject obj, bool value)
26
        {
27
            obj.SetValue(IsEnabledProperty, value);
28
        }
29

    
30
        // 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
        {
36
            RadGridView grid = d as RadGridView;
37

    
38
            if (grid != null)
39
            {
40
                var behavior = new GridViewAutoWidthBehavior(grid);
41
            }
42
        }
43

    
44
        public GridViewAutoWidthBehavior(RadGridView grid)
45
        {
46
            this.gridView = grid;
47
            if (this.gridView != null)
48
            {
49
                this.gridView.LoadingRowDetails += new EventHandler<Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs>(OnLoadingRowDetails);
50
            }
51
        }
52

    
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
    }
61
}
클립보드 이미지 추가 (최대 크기: 500 MB)