Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
Identifying which column header was clicked in a CardView grid
posted

Hello,

I have a grid with CardView = true. As a result all the headers become labels located to the left of each card.

I want to execute some logic when the user clicks a particular header. I am handling the MouseClick event and then I get the UIElement using the ElementFromPoint method.

At runtime I noticed the the UIElement being clicked is of type TextUIElement, which makes sense because headers become labels in a CardView grid. My question is: How do I identify the grid column corresponding to that TextUIElement?

The only thing I have is the text of the TextUIElement, which corresponds to the header caption. That's not good enough since the caption can change at runtime (it's localized).

Any ideas?

Parents
  • 469350
    Verified Answer
    Offline posted

    oscarmorasu said:
    At runtime I noticed the the UIElement being clicked is of type TextUIElement, which makes sense because headers become labels in a CardView grid. My question is: How do I identify the grid column corresponding to that TextUIElement?

    TextUIElement is just an element that displays text. This is not related to CardView. The normal view headers will also contain TextUIElements.

    Either way, it doesn't really matter. What you have to do is call GetContext on the element you get. GetContext will walk up the element chain until it finds an element that has a context of the type you specified. So in this case, it will probably get the context from the parent element that contains the TextUIElement.

    Try passing in a type of UltraGridColumn. That may not work, and if it does not, try ColumnHeader, instead. Then you can get the column from the ColumnHeader's Column property.

    Just or fun, or to learn more about the UIElements in the grid, you might want to get the Infragistics UIElementViewer Utility. This utility will allow you to actually see the UIElements at any particular point in the grid, so it will be a huge help when working with UIElements for any reason.

Reply Children
No Data