4

I see the following behavior with a WPF Datagrid. When there are more items then the height of the view area, the vertical scroll is available. When I click on the last row in the view, an automatic scroll occurs where the row that was just below the last comes into view.

The first column of the datagrid is a checkbox. When the user clicks on this last row, I'm not getting the event for checkbox clicks. The checkboxes in all other rows work OK.

I'd like to disable the automatic scroll, but can't figure how to do it.

<Style x:Key="SingleClickEditing"  TargetType="{x:Type toolkit:DataGridCell}">
     <EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
     <EventSetter Event="CheckBox.Unchecked" Handler="OnChecked"/>
</Style>
2
  • there's no such thing as "CSharp". The language is named "C#". Commented Jun 20, 2011 at 18:59
  • 3
    And is pronounced "COctothorpe". :) Commented Jun 20, 2011 at 19:42

2 Answers 2

3

I found the solution here: WPF DataGrid: how do I stop auto scrolling when a cell is clicked?

I changed the style of the DataGrid

 <Style x:Key="SingleClickEditing"  TargetType="{x:Type toolkit:DataGridCell}">
       <EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
       <EventSetter Event="CheckBox.Unchecked" Handler="OnChecked"/>
       <EventSetter Event="Control.RequestBringIntoView" Handler="DataGrid_Documents_RequestBringIntoView"  />
 </Style>


private void DataGrid_Documents_RequestBringIntoView(object sender,    RequestBringIntoViewEventArgs e)
{
    e.Handled = true;
}
Sign up to request clarification or add additional context in comments.

Comments

0

There is a property on the Datagrid that you should be able to set that would determine if Vertical, Horizontal, Both, or None (in regards to scroll bars) are visible.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.