Home Forums WPF controls Xceed DataGrid for WPF WPF KeyBinding for Enter key does not work (But does work on DevExpress grid)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #40133 |

    So, I convinced my team that Xceed has the better WPF Grid.  I talked
    them into moving over from Dev Express.  I got my boss to put it in the
    budget to purchase (we are planning to purchase in July (the start of
    our fiscal year)).

    Since it was all a done deal, I figured, lets
    start switching our DevExpress grid out for our shiny new Xceed grid
    (using the Demo).  It was all rainbows and butterflies until we got to
    the InputBindings.

    Our DevExpress grid is setup similar to this:

    <dxg:GridControl ItemsSource="{Binding MySource, Mode=TwoWay}">
        <dxg:GridControl.Columns>
            <dxg:GridColumn Header="Name" Width="100" DisplayMemberBinding="{Binding ItemObject}" />
        </dxg:GridControl.Columns>
        <dxg:GridControl.View>
            <dxg:TableView FocusedRow="{Binding MySelectedItem, Mode=TwoWay}" />                    
        </dxg:GridControl.View> 
        <dxg:GridControl.InputBindings>
            <KeyBinding Key="Enter" Command="{Binding SelectItemCommand}" />
        </dxg:GridControl.InputBindings>
    </dxg:GridControl>

    That all works fine with DevExpress’s grid.  We then went and swapped out the DevExpress grid for the Xceed grid like this: (I removed extra properties)

    <xcdg:DataGridControl ItemsSource="{Binding MySource, Mode=TwoWay}" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}">
        <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="ItemObject" Title="Name" Width="100" IsMainColumn="True" />
        </xcdg:DataGridControl.Columns>
        <xcdg:DataGridControl.View>
            <xcdg:TableView >
                <xcdg:TableView.FixedHeaders>
                    <DataTemplate>
                        <xcdg:ColumnManagerRow AllowColumnReorder="False"/>
                    </DataTemplate>
                </xcdg:TableView.FixedHeaders>
            </xcdg:TableView>
        </xcdg:DataGridControl.View>
        <xcdg:DataGridControl.InputBindings>         <KeyBinding Key="Enter" Command="{Binding SelectItemCommand}" CommandTarget="{Binding ElementName=GridControl}"/>     </xcdg:DataGridControl.InputBindings> </xcdg:DataGridControl>
    The big difference here is that the Dev Express one works like we would expect 
    (pressing enter while in the grid causes the Select Item Command to fire). But the Xceed grid
    does not work. Pressing enter does nothing.... Why?
    I am really hoping that the Xceed grid is actually better than the Dev Express grid and there is 
    a nice easy way to get my enter key to fire my command. (So I don't look like I got us to change to a worse grid.)
    Can someone please let me know how to setup this KeyBinding?
    (NOTE: Other keyBindings work just fine, so it is not a syntax error or some such thing.) 
     

    Imported from legacy forums. Posted by Stephen (had 2520 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Stephen,

    The Enter key is most likely being handled by the DataGrid and not making its way to your command.

    We do expose Preview events that allow you to capture the Up/Down of key or mouse presses.

    For example, in your scenario, you would want the PreviewKeyUp (or Down, depending which behavior you prefer):

       <xcdg:DataGridControl x:Name=”myGrid” PreviewKeyUp=”myGrid_PreviewKeyUp” … >

       private void myGrid_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e)
       {
          if (e.Key == Key.Enter)
          {
             // your code here
          }
       }

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 1104 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes that would work if I was doing WinForms style programming.

    One of the reasons we are switching (well now it is downgraded to thinking about switching) to Xceed is because it was supposed to have MVVM support.

    I was hoping to not have to use events for things that should be commands.  Or have to hack events into commands… (yes I know it can be done). I was looking (and thought I had found) a grid that can do MVVM out of the box.

    Imported from legacy forums. Posted by Stephen (had 564 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Stephen,

    I did not know that you were working in MVVM. I will look for another solution.

    Imported from legacy forums. Posted by Diane [Xceed] (had 353 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Stephen,

    While we do want to properly support MVVM, there are obviously still some situations that we did not think of.

    After verification with developers, we will open a new feature request to properly allow the Enter key press to bubble back up to the surface. Unfortunately, it is not something that would be done in the short term, as it might cause many behavior changes that we would have to make sure to properly handle.

    As a quick note, if your plan was to purchase the Blueprint Edition, that would give you access to the source code, and would therefore allow you to make any changes you want and compile a custom version of the DataGrid.

    We will post an update in this forum thread when the feature request is done and available for download. Thank you for your patience.

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 1077 views)

    HanzieV
    Participant
    Post count: 13

    Any update on this ?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.