-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
132 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
|
||
namespace Cirilla.Avalonia.Controls | ||
{ | ||
public class DataGridTextExColumn : DataGridTextColumn | ||
{ | ||
public static readonly StyledProperty<bool> AcceptsReturnProperty = | ||
AvaloniaProperty.Register<DataGridTextExColumn, bool>(nameof(AcceptsReturn)); | ||
|
||
public bool AcceptsReturn | ||
{ | ||
get { return GetValue(AcceptsReturnProperty); } | ||
set { SetValue(AcceptsReturnProperty, value); } | ||
} | ||
|
||
protected override IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem) | ||
{ | ||
var element = base.GenerateEditingElementDirect(cell, dataItem); | ||
if (element is TextBox textBox) | ||
textBox.AcceptsReturn = AcceptsReturn; | ||
return element; | ||
} | ||
|
||
protected override object PrepareCellForEdit(IControl editingElement, RoutedEventArgs editingEventArgs) | ||
{ | ||
if (editingElement is TextBox textBox) | ||
textBox.AcceptsReturn = AcceptsReturn; | ||
return base.PrepareCellForEdit(editingElement, editingEventArgs); | ||
} | ||
|
||
protected override void RefreshCellContent(IControl element, string propertyName) | ||
{ | ||
if (element is TextBox textBox) | ||
textBox.AcceptsReturn = AcceptsReturn; | ||
base.RefreshCellContent(element, propertyName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters