locked
Synchronizing scrollviewer scroll with datagrid scroll RRS feed

  • Question

  • Hi

    I have a scrollviewer which contains a datagrid. I want to scroll the grid when user scrolls the scrollviewer scroll so that the datagrid header appears to be fixed. Is it possible or is there any other workaround.

    Thanks


    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 3:59 AM

Answers

  • Hello,

    you can do it with a view model:

    1. Define a property that has a Boolean value that is true when the CheckBox must be enabled and false when it must be disabled.
    2. When one of the properties in the condition change, recalculate the value of the property. If the value of the property changes, you must notify that it has changed.
    3. Bind the IsEnabled property of the CheckBox to this property.

    And now it will work with virtualization.

    Patrick

    Friday, September 13, 2013 6:44 AM
  • Thanks Patrick for your solution. but I used a workaround by disabling virtualization (by Editing datagrid template). Now it works. :)


    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 10:34 AM

All replies

  • Hello,

    just remove the ScrollViewer, the DataGrid content will scroll without the header moving.

    Patrick

    Friday, September 13, 2013 4:35 AM
  • Hi

    I cannot remove scrollviewer as I am facing problem of grid virtualization if it is not.


    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 6:10 AM
  • Hello,

    which problem of grid virtualization?

    Patrick

    Friday, September 13, 2013 6:16 AM
  • I am manipulating cells on my datagrid _RowLoading Event. So on scrolling using datagrid scroll everythings get messed up. I also tried disabling grid virtualization but got no success.

    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 6:28 AM
  • Hello,

    you should never manipulate directly the cells on the data grid. You must use a view model and bind its properties to the cell contents.

    If you have a specific scenario that doesn't work with bindings, please explain it.

    Patrick
    Friday, September 13, 2013 6:33 AM
  • In my datagrid 1st column contains checkbox. I want to disable that checkbox when some condition is met. That disabling code is written in  RowLoading.

    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 6:37 AM
  • Hello,

    you can do it with a view model:

    1. Define a property that has a Boolean value that is true when the CheckBox must be enabled and false when it must be disabled.
    2. When one of the properties in the condition change, recalculate the value of the property. If the value of the property changes, you must notify that it has changed.
    3. Bind the IsEnabled property of the CheckBox to this property.

    And now it will work with virtualization.

    Patrick

    Friday, September 13, 2013 6:44 AM
  • Thanks Patrick for your solution. but I used a workaround by disabling virtualization (by Editing datagrid template). Now it works. :)


    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.

    Friday, September 13, 2013 10:34 AM