|
<Syncfusion:GridTemplateColumn HeaderText="Envasador" MaximumWidth="90">
<Syncfusion:GridTemplateColumn.EditTemplate>
<DataTemplate>
<Syncfusion:AutoComplete Focusable="True" CustomSource="{Binding Path=DataContext.Envasadores, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
StringMode="AnyChar" SelectedItem="{Binding Path=Envasador}" Name="Provincia" DisplayMemberPath="NombreCompleto"
Syncfusion:FocusManagerHelper.FocusedElement="True"/>
</DataTemplate>
</Syncfusion:GridTemplateColumn.EditTemplate>
<Syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Envasador.NombreCompleto}"/>
</DataTemplate>
</Syncfusion:GridTemplateColumn.CellTemplate>
</Syncfusion:GridTemplateColumn> |
|
this.dataGrid.PreviewKeyDown+=dataGrid_PreviewKeyDown;
void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (!this.dataGrid.SelectionController.CurrentCellManager.HasCurrentCell)
return;
if(this.dataGrid.SelectionController.CurrentCellManager.CurrentCell.IsEditing)
return;
this.dataGrid.SelectionController.CurrentCellManager.BeginEdit();
} |
hi im trying to use syncfusion autocomplete text in my project i want to change the color of a label while i focus on the autocomplete
can u please help me how to achieve it i even tried Focusable="True" but it is throwing an error saying no know element Focusable
and i generated focused event but break point is not hitting the events and it is not working
how to achieve this in xamarin forms
here is the code
Hi David,You can achieve your requirement to go to edit mode on the TemplateColumn when typing any letter by wiring PreviewKeyDown event like below,
this.dataGrid.PreviewKeyDown+=dataGrid_PreviewKeyDown;void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e){if (!this.dataGrid.SelectionController.CurrentCellManager.HasCurrentCell)return;if(this.dataGrid.SelectionController.CurrentCellManager.CurrentCell.IsEditing)return;this.dataGrid.SelectionController.CurrentCellManager.BeginEdit();}Regards,Jai Ganesh S
|
void AssociatedObject_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (!this.AssociatedObject.SelectionController.CurrentCellManager.HasCurrentCell)
return;
if (this.AssociatedObject.SelectionController.CurrentCellManager.CurrentCell.IsEditing)
return;
//Here need to call the Beginedit method for GridTempaletColumn
if (this.AssociatedObject.Columns[this.AssociatedObject.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex - 1] is GridTemplateColumn)
this.AssociatedObject.SelectionController.CurrentCellManager.BeginEdit();
}
protected override void OnTextInput(TextCompositionEventArgs e)
{
if (!SelectionController.CurrentCellManager.HasCurrentCell)
{
base.OnTextInput(e);
return;
}
//Get the Current Row and Column index from the CurrentCellManager
var rowColumnIndex = SelectionController.CurrentCellManager.CurrentRowColumnIndex;
var dataGrid = e.OriginalSource as SfDataGridExt;
RowGenerator rowGenerator = dataGrid.RowGenerator;
var dataRow = rowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowColumnIndex.RowIndex);
List<DataColumnBase> visiblecolumn = dataRow.VisibleColumns;
if (dataRow != null && dataRow is DataRow)
{
//Get the column from the VisibleColumn collection based on the column index
var dataColumn = visiblecolumn.FirstOrDefault(column => column.ColumnIndex == rowColumnIndex.ColumnIndex);
//Convert the input text to char type
char text;
char.TryParse(e.Text, out text);
//Skip if the column is GridTemplateColumn and the column is not already in editing
//Allow Editing only pressed letters digits and Minus sign key
if (dataColumn != null && !(dataColumn.GridColumn is GridTemplateColumn) && !dataColumn.IsEditing &&
SelectionController.CurrentCellManager.BeginEdit() &&
(e.Text.Equals(".") || char.IsLetterOrDigit(text)))
dataColumn.Renderer.PreviewTextInput(e);
}
base.OnTextInput(e);
} |