How to get the Style set by a StyleSelector in a GridViewCell

2 posts, 0 answers
  1. George
    George avatar
    6 posts
    Member since:
    May 2011

    Posted 19 May 2011 Link to this post

    I have a GridViewCell whose style has been set by a StyleSelector.

    The style is a ControlTemplate that contains a Border which wraps a VisualStateManager (actually an attached property on the Border), a ContentPresenter, and a ToolTipService.ToopTip (which is also an attached property on the border).  The Border has a name, PART_CellBorder.

    The ToolTip within the ToolTipService contains a collection of InteractionBehaviors which contains a single behavior, LoadToolTipTextBehavior, I'm after.

    In the RadGrid's RowUnloaded event handler I need to invoke the Detach() method of the LoadToopTipTextBehavior.  I've done this in other cases with xaml defined behaviors, but not when the style has been set by a StyleSelector.  How can I get a reference to the Border? 

    In the past I've drilled down into a ControlTemplate to get a reference to one of its named elements, but in this case the StyleSelector has set the Style and I have not been able to find how to get access to the style, and thus the ControlTemplate.

    Thanks in advance,

    George

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 20 May 2011 Link to this post

    Hello George,

    In this case setting a style utilizing style selectors is not  different from setting the Style property manually, so you can access it by checking the property. However, I wouldn't advise you to do this, because getting the setter that sets this control template wouldn't help you very much. You'd better try iterating the visual tree to find the element you are seeking for and access it from there. Please, refer to the attached example property.

    All the best,
    Ivan Ivanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top