move GridExtension.cs to Controls/Attach/GridAttach.cs

This commit is contained in:
NaBian committed 2021-06-21 22:21:38 +08:00
1 parent 0848d2b6dd
commit 3bcc29ba43
2 files changed
+16 -28

No files matched your search

@@ -2,28 +2,23 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
namespace HandyControl.Tools.Extension namespace HandyControl.Controls
{ {
public class GridExtensions public class GridAttach
{ {
public static readonly DependencyProperty NameProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty NameProperty = DependencyProperty.RegisterAttached(
"Name", typeof(string), typeof(GridExtensions), new PropertyMetadata(default(string))); "Name", typeof(string), typeof(GridAttach), new PropertyMetadata(default(string)));
public static void SetName(DependencyObject element, string value) public static void SetName(DependencyObject element, string value)
{ => element.SetValue(NameProperty, value);
element.SetValue(NameProperty, value);
}
public static string GetName(DependencyObject element) public static string GetName(DependencyObject element)
{ => (string)element.GetValue(NameProperty);
return (string) element.GetValue(NameProperty);
}
public static readonly DependencyProperty RowNameProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty RowNameProperty = DependencyProperty.RegisterAttached(
"RowName", typeof(string), typeof(GridExtensions), "RowName", typeof(string), typeof(GridAttach), new PropertyMetadata(default(string), OnRowNameChanged));
new PropertyMetadata(default(string), RowName_PropertyChanged));
private static void RowName_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnRowNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
if (d is FrameworkElement frameworkElement) if (d is FrameworkElement frameworkElement)
{ {
@@ -40,6 +35,7 @@ namespace HandyControl.Tools.Extension
{ {
var gridRowDefinition = grid.RowDefinitions[i]; var gridRowDefinition = grid.RowDefinitions[i];
var gridRowName = GetName(gridRowDefinition); var gridRowName = GetName(gridRowDefinition);
if (!string.IsNullOrEmpty(gridRowName) && if (!string.IsNullOrEmpty(gridRowName) &&
gridRowName.Equals(rowName, StringComparison.Ordinal)) gridRowName.Equals(rowName, StringComparison.Ordinal))
{ {
@@ -53,20 +49,15 @@ namespace HandyControl.Tools.Extension
} }
public static void SetRowName(DependencyObject element, string value) public static void SetRowName(DependencyObject element, string value)
{ => element.SetValue(RowNameProperty, value);
element.SetValue(RowNameProperty, value);
}
public static string GetRowName(DependencyObject element) public static string GetRowName(DependencyObject element)
{ => (string)element.GetValue(RowNameProperty);
return (string) element.GetValue(RowNameProperty);
}
public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty ColumnNameProperty = DependencyProperty.RegisterAttached(
"ColumnName", typeof(string), typeof(GridExtensions), "ColumnName", typeof(string), typeof(GridAttach), new PropertyMetadata(default(string), OnColumnNameChanged));
new PropertyMetadata(default(string), ColumnName_PropertyChanged));
private static void ColumnName_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnColumnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
if (d is FrameworkElement frameworkElement) if (d is FrameworkElement frameworkElement)
{ {
@@ -83,6 +74,7 @@ namespace HandyControl.Tools.Extension
{ {
var gridColumnDefinition = grid.ColumnDefinitions[i]; var gridColumnDefinition = grid.ColumnDefinitions[i];
var gridColumnName = GetName(gridColumnDefinition); var gridColumnName = GetName(gridColumnDefinition);
if (!string.IsNullOrEmpty(gridColumnName) && if (!string.IsNullOrEmpty(gridColumnName) &&
gridColumnName.Equals(columnName, StringComparison.Ordinal)) gridColumnName.Equals(columnName, StringComparison.Ordinal))
{ {
@@ -96,13 +88,9 @@ namespace HandyControl.Tools.Extension
} }
public static void SetColumnName(DependencyObject element, string value) public static void SetColumnName(DependencyObject element, string value)
{ => element.SetValue(ColumnNameProperty, value);
element.SetValue(ColumnNameProperty, value);
}
public static string GetColumnName(DependencyObject element) public static string GetColumnName(DependencyObject element)
{ => (string)element.GetValue(ColumnNameProperty);
return (string) element.GetValue(ColumnNameProperty);
}
} }
} }
@@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DataGridAttach.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DataGridAttach.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DropDownElement.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DropDownElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\EdgeElement.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\EdgeElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\GridAttach.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconElement.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconSwitchElement.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\IconSwitchElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\ImageAttach.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\ImageAttach.cs" />
@@ -143,7 +144,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DependencyObjectExtension.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DependencyObjectExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\GridExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\LangExtension.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\LangExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />