forked from MaterialDesignInXAML/MaterialDesignInXamlToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataGridTextColumn.cs
More file actions
27 lines (23 loc) · 806 Bytes
/
Copy pathDataGridTextColumn.cs
File metadata and controls
27 lines (23 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Windows;
using System.Windows.Controls;
namespace MaterialDesignThemes.Wpf
{
public class DataGridTextColumn : System.Windows.Controls.DataGridTextColumn
{
protected override object? PrepareCellForEdit(FrameworkElement? editingElement, RoutedEventArgs editingEventArgs)
{
if (editingElement is TextBox textBox)
{
textBox.MaxLength = MaxLength;
textBox.SelectionStart = textBox.Text.Length;
}
editingElement?.Focus();
return null;
}
/// <summary>
/// Set the maximum length for the text field.
/// </summary>
/// <remarks>Not a dependency property, as is only applied once.</remarks>
public int MaxLength { get; set; }
}
}