This is a migrated thread and some comments may be shown as answers.

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

1 Answer 25 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 19 May 2011, 09:40 PM

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

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 20 May 2011, 08:03 AM
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
Tags
General Discussions
Asked by
George
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or