日期:2014-05-17  浏览次数:21117 次

WPF,模板,这句为什么没对
一个Button的模板,其中的Grid元素:
<Grid Margin="4" Background="{TemplateBinding Property=Button.Background}">


这样写,为什么报错呢?

而下面这句是不报错的:
<TextBlock Text="{TemplateBinding Property=Button.Content}" />

------解决方案--------------------
<TextBlock Text="{TemplateBinding Property=Button.Content}"  Background="{TemplateBinding Property=Button.Background}"  />
这样可以吗?

------解决方案--------------------
Grid 是 布局容器 引用 Button的模板?
------解决方案--------------------
引用:
Quote: 引用:

<TextBlock Text="{TemplateBinding Property=Button.Content}"  Background="{TemplateBinding Property=Button.Background}"  />
这样可以吗?

不知为什么,可以运行,运行之后,就不报错了,再次改为Button.就报错,但任然可以运行


有的时候,重启VS或者重启电脑 可以解决很多灵异事件哦
------解决方案--------------------
你用TemplateBinding加个Button.干什么?
画蛇添足。