This is a migrated thread and some comments may be shown as answers.

CustomKeyboardCommandProvider example has trouble when Grid uses cell edit templates

1 Answer 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 11 Apr 2018, 07:07 PM

I am having trouble with the order of events being called when using the custom keyboard command example code.  

I want to change the behavior of the enter key to exactly what the example is doing. This works great until I add a cell datatemplate and an edit cell data template. 

Before changing the example everything is working fine.  The behavior is as follows: 

1. Start editing a value

2. Using the mouse set focus on some other field( thus comiting the edit) OR pressing enter on the keyboard 

3. The property setter for statdiumcapacity is called

4. The ClubsGrid_OnCellEditEnded callback is called.

After adding in a cell template and an edit cell template as follows: 

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:my="clr-namespace:CustomKeyboardCommandProvider"
        Title="MainWindow" Height="300" Width="700">
    <Window.Resources>
        <my:MyViewModel x:Key="MyViewModel"/>

      <DataTemplate x:Key="DataTemplate">
        <TextBlock Text="{Binding StadiumCapacity}" TextAlignment="Center"/>
      </DataTemplate>
        
      <DataTemplate x:Key="EditDataTemplate">
      <TextBox Text="{Binding StadiumCapacity}"  />
      </DataTemplate>

  </Window.Resources>
    <Grid DataContext="{StaticResource MyViewModel}">       
        <telerik:RadGridView Name="clubsGrid"  BeginningEdit="ClubsGrid_OnBeginningEdit" CellEditEnded="ClubsGrid_OnCellEditEnded" AutoGenerateColumns="False"
                             ItemsSource="{Binding Clubs}">
          <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Stadium Cap" Width="200" CellTemplate="{StaticResource DataTemplate}" CellEditTemplate="{StaticResource EditDataTemplate}" />
            </telerik:RadGridView.Columns>
    </telerik:RadGridView>
    </Grid>
</Window>

 

Now the sequence changes.  The mouse setting focus away from the edit works as before.  However, the enter key does not

1. Start editing a value
2. Press enter on the keyboard while still editing.
3. The ClubsGrid_OnCellEditEnded callback is called.

4. The property setter for statdiumcapacity is called

 

The order is reversed?  What am I missing to make the behaviour the same using datatemplates as not using datatemplates

 

1 Answer, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 12 Apr 2018, 01:21 PM
I found it.  Make the TextBlock text binding Mode=TwoWay then everything works as expected. 
Tags
GridView
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Share this question
or