【发布时间】:2011-07-21 13:33:35
【问题描述】:
<Style x:Key="abc" TargetType="{x:Type Window}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<button x:name="btn">my button!!</button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
...
<Window ... Style="{StaticResource styleMainWindow}">
如何使用按钮btn?
不辜负您的期望,
MessageBox.Show(this.btn1.name);
在编译时发生错误。而且 btn1 也没有出现在智能感知中。
【问题讨论】:
-
您是在尝试创建无外观控件还是 UserControl?