Git Product home page Git Product logo

how-to-begin-edit-on-tab-key-navigation-in-xamarin.forms-datagrid's Introduction

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.

how-to-begin-edit-on-tab-key-navigation-in-xamarin.forms-datagrid's People

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

karthikraja26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.