Skip to content

Commit 3bcc29b

Browse files
committed
move GridExtension.cs to Controls/Attach/GridAttach.cs
1 parent 0848d2b commit 3bcc29b

2 files changed

Lines changed: 16 additions & 28 deletions

File tree

src/Shared/HandyControl_Shared/Tools/Extension/GridExtension.cs renamed to src/Shared/HandyControl_Shared/Controls/Attach/GridAttach.cs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@
22
using System.Windows;
33
using 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
}

src/Shared/HandyControl_Shared/HandyControl_Shared.projitems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DataGridAttach.cs" />
1616
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DropDownElement.cs" />
1717
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\EdgeElement.cs" />
18+
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\GridAttach.cs" />
1819
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconElement.cs" />
1920
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconSwitchElement.cs" />
2021
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\ImageAttach.cs" />
@@ -143,7 +144,6 @@
143144
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" />
144145
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DependencyObjectExtension.cs" />
145146
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" />
146-
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\GridExtension.cs" />
147147
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\LangExtension.cs" />
148148
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
149149
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />

0 commit comments

Comments
 (0)