Skip to content

This repository contains the sample about how to begin edit on tab key navigation in Xamarin.Forms DataGrid

Notifications You must be signed in to change notification settings

SyncfusionExamples/how-to-begin-edit-on-tab-key-navigation-in-Xamarin.Forms-DataGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

how-to-begin-edit-on-tab-key-navigation-in-Xamarin.Forms-DataGrid

##About the sample This example illustrates how to begin edit on tab key navigation in Xamarin.Forms SfDataGrid.

By default, the SfDataGrid does not allow to enter edit mode while navigating the cell by using Tab key. But you can allow to enter edit mode by customizing the “Tab” key functionality by overriding ProcessKeyDown() method in custom selection controller and begin the editing action by calling SfDataGrid.BeginEdit() method in ProcessKeyDown() method when Tab key processed.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DataGridDemo"
             xmlns:sfPager="clr-namespace:Syncfusion.SfDataGrid.XForms.DataPager;assembly=Syncfusion.SfDataGrid.XForms"
             xmlns:sfGrid="clr-namespace:Syncfusion.SfDataGrid.XForms;assembly=Syncfusion.SfDataGrid.XForms"
             x:Class="DataGridDemo.MainPage" >
    <ContentPage.Resources>
        <local:CustomSelectionController x:Key="CustomSelectionController" />
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Orientation="Vertical">
            <sfGrid:SfDataGrid x:Name="textGrid" 
                               ItemsSource="{Binding OrdersInfo}" 
                               SelectionController="{x:StaticResource CustomSelectionController}"
                               ColumnSizer="Star" NavigationMode="Cell" 
                               SelectionMode="Single" AllowEditing="True">
            </sfGrid:SfDataGrid>
        </StackLayout>
      
    </ContentPage.Content>
</ContentPage>
public partial class MainPage : ContentPage, INotifyPropertyChanged
    {
        ViewModel viewModel;
        public MainPage()
        {
            InitializeComponent();
            viewModel = new ViewModel();
            this.BindingContext = viewModel;
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
        }
    }

    public class CustomSelectionController : GridSelectionController
    {
        public CustomSelectionController()
        {
            this.SelectedRows = new GridSelectedRowsCollection();
        }

        protected override void ProcessKeyDown(string keyCode, bool isCtrlKeyPressed, bool isShiftKeyPressed)
        {
            if (keyCode == "Tab")
            {
                this.DataGrid.BeginEdit(1,0);
            }
            else
            {
                // default key action
                base.ProcessKeyDown(keyCode, isCtrlKeyPressed, isShiftKeyPressed);
            }
        }
    }

Requirements to run the demo

Troubleshooting

Path too long exception

If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.

About

This repository contains the sample about how to begin edit on tab key navigation in Xamarin.Forms DataGrid

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages