22using System . Windows ;
33using System . Windows . Controls ;
44
5- namespace HandyControl . Tools . Extension
5+ namespace HandyControl . Controls
66{
7- public class GridExtensions
7+ public class GridAttach
88 {
99 public static readonly DependencyProperty NameProperty = DependencyProperty . RegisterAttached (
10- "Name" , typeof ( string ) , typeof ( GridExtensions ) , new PropertyMetadata ( default ( string ) ) ) ;
10+ "Name" , typeof ( string ) , typeof ( GridAttach ) , new PropertyMetadata ( default ( string ) ) ) ;
1111
1212 public static void SetName ( DependencyObject element , string value )
13- {
14- element . SetValue ( NameProperty , value ) ;
15- }
13+ => element . SetValue ( NameProperty , value ) ;
1614
1715 public static string GetName ( DependencyObject element )
18- {
19- return ( string ) element . GetValue ( NameProperty ) ;
20- }
16+ => ( string ) element . GetValue ( NameProperty ) ;
2117
2218 public static readonly DependencyProperty RowNameProperty = DependencyProperty . RegisterAttached (
23- "RowName" , typeof ( string ) , typeof ( GridExtensions ) ,
24- new PropertyMetadata ( default ( string ) , RowName_PropertyChanged ) ) ;
19+ "RowName" , typeof ( string ) , typeof ( GridAttach ) , new PropertyMetadata ( default ( string ) , OnRowNameChanged ) ) ;
2520
26- private static void RowName_PropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
21+ private static void OnRowNameChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
2722 {
2823 if ( d is FrameworkElement frameworkElement )
2924 {
@@ -40,6 +35,7 @@ private static void RowName_PropertyChanged(DependencyObject d, DependencyProper
4035 {
4136 var gridRowDefinition = grid . RowDefinitions [ i ] ;
4237 var gridRowName = GetName ( gridRowDefinition ) ;
38+
4339 if ( ! string . IsNullOrEmpty ( gridRowName ) &&
4440 gridRowName . Equals ( rowName , StringComparison . Ordinal ) )
4541 {
@@ -53,20 +49,15 @@ private static void RowName_PropertyChanged(DependencyObject d, DependencyProper
5349 }
5450
5551 public static void SetRowName ( DependencyObject element , string value )
56- {
57- element . SetValue ( RowNameProperty , value ) ;
58- }
52+ => element . SetValue ( RowNameProperty , value ) ;
5953
6054 public static string GetRowName ( DependencyObject element )
61- {
62- return ( string ) element . GetValue ( RowNameProperty ) ;
63- }
55+ => ( string ) element . GetValue ( RowNameProperty ) ;
6456
6557 public static readonly DependencyProperty ColumnNameProperty = DependencyProperty . RegisterAttached (
66- "ColumnName" , typeof ( string ) , typeof ( GridExtensions ) ,
67- new PropertyMetadata ( default ( string ) , ColumnName_PropertyChanged ) ) ;
58+ "ColumnName" , typeof ( string ) , typeof ( GridAttach ) , new PropertyMetadata ( default ( string ) , OnColumnNameChanged ) ) ;
6859
69- private static void ColumnName_PropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
60+ private static void OnColumnNameChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
7061 {
7162 if ( d is FrameworkElement frameworkElement )
7263 {
@@ -83,6 +74,7 @@ private static void ColumnName_PropertyChanged(DependencyObject d, DependencyPro
8374 {
8475 var gridColumnDefinition = grid . ColumnDefinitions [ i ] ;
8576 var gridColumnName = GetName ( gridColumnDefinition ) ;
77+
8678 if ( ! string . IsNullOrEmpty ( gridColumnName ) &&
8779 gridColumnName . Equals ( columnName , StringComparison . Ordinal ) )
8880 {
@@ -96,13 +88,9 @@ private static void ColumnName_PropertyChanged(DependencyObject d, DependencyPro
9688 }
9789
9890 public static void SetColumnName ( DependencyObject element , string value )
99- {
100- element . SetValue ( ColumnNameProperty , value ) ;
101- }
91+ => element . SetValue ( ColumnNameProperty , value ) ;
10292
10393 public static string GetColumnName ( DependencyObject element )
104- {
105- return ( string ) element . GetValue ( ColumnNameProperty ) ;
106- }
94+ => ( string ) element . GetValue ( ColumnNameProperty ) ;
10795 }
10896}
0 commit comments