Accessing other controls by name in a Silverlight ControlTemplate

Posted by Chris S on Stack Overflow See other posts from Stack Overflow or by Chris S
Published on 2010-05-05T15:09:15Z Indexed on 2010/05/05 16:18 UTC
Read the original article Hit count: 363

I have a custom control that inherits from ContentControl. Inside the generic.xaml file is a simple Grid with 2 rows:

  • Row 1 - A toggle button
  • Row 2 - A StackPanel with a TextBlock, named "Stackpanel1"

The ToggleButton has its own nested ControlTemplate which has VisualStates for Checked/Unchecked.

Is it possible to reference "Stackpanel1" from inside the ToggleButton's control template somehow? In order to show or hide the stackpanel.

© Stack Overflow or respective owner

Related posts about silverlight-3.0

Related posts about controltemplate