123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using InABox.Core;
- using InABox.WPF;
- using Syncfusion.UI.Xaml.Grid;
- namespace InABox.DynamicGrid;
- public class DynamicGridUniqueCodeColumn<TEntity> : DynamicGridEditorColumn<TEntity,UniqueCodeEditor,GridTemplateColumn> where TEntity : BaseObject
- {
- protected override void Configure(GridTemplateColumn column, UniqueCodeEditor editor)
- {
- column.CellTemplate = TemplateGenerator.CreateDataTemplate
- (
- () =>
- {
- var result = new Label();
- result.HorizontalContentAlignment = Column.TextAlignment == TextAlignment.Left
- ? HorizontalAlignment.Left
- : Column.TextAlignment == TextAlignment.Center
- ? HorizontalAlignment.Center
- : HorizontalAlignment.Right;
- var binding = new Binding()
- {
- Path = new PropertyPath(MappingName),
- };
- result.SetBinding(Label.ContentProperty, binding);
- return result;
- }
- );
- column.EditTemplate = TemplateGenerator.CreateDataTemplate
- (
- () =>
- {
- var textbox = new TextBox();
- textbox.CharacterCasing = CharacterCasing.Upper;
- textbox.TextAlignment = Column.TextAlignment;
- textbox.SetBinding(TextBox.TextProperty, new Binding()
- {
- Path = new PropertyPath(MappingName)
- });
-
- textbox.SetValue(Grid.ColumnSpanProperty, 2);
- textbox.Padding = new Thickness(2, 0, 0, 0);
- textbox.VerticalContentAlignment = VerticalAlignment.Center;
- textbox.PreviewTextInput += (sender, args) => textbox.Tag = true;
- textbox.TextChanged += (sender, args) =>
- {
- if (Equals(textbox.Tag, false))
- {
- textbox.SelectAll();
- textbox.Tag = true;
- }
- };
- textbox.SetValue(FocusManagerHelper.FocusedElementProperty, true);
-
- return textbox;
- }
- );
- }
-
- public DynamicGridUniqueCodeColumn(DynamicGridColumn definition) : base(definition)
- {
- }
- }
|