Problem reading AttachedProperty in ControlTemplate
问题 This is my attached property: public class MyButtonThing { public static string GetText2(DependencyObject obj) { return (string)obj.GetValue(Text2Property); } public static void SetText2(DependencyObject obj, string value) { obj.SetValue(Text2Property, value); } public static readonly DependencyProperty Text2Property = DependencyProperty.RegisterAttached("Text2", typeof(string), typeof(System.Windows.Controls.Button)); } This is my ControlTemplate: EDIT this will work fine: <Window.Resources>