== ControlTemplate == Code behind: == How to: Find ControlTemplate-Generated Elements == A simple ControlTemplate for Button: To find an element within the template after the template has been applied: // Finding the grid that is generated by the ControlTemplate of the Button Grid gridInTemplate = (Grid)myButton1.Template.FindName("grid", myButton1); // Do something to the ControlTemplate-generated grid MessageBox.Show("The actual width of the grid in the ControlTemplate: " + gridInTemplate.GetValue(Grid.ActualWidthProperty).ToString()); Source: [[http://msdn.microsoft.com/en-us/library/bb613586.aspx|MSDN: How to: Find ControlTemplate-Generated Elements]]