【发布时间】:2010-08-03 10:00:50
【问题描述】:
我正在覆盖 Button 的 Content。我的问题是,当我这样做时,按钮的默认 Style 会被覆盖。
如何保留旧样式(旧样式定义鼠标悬停、鼠标移出效果等)?
这是我的代码:
<Fluent:DropDownButton SizeDefinition="Small">
<Fluent:DropDownButton.Template>
<ControlTemplate>
<StackPanel>
<Label Content="A" FontFamily="Times New Roman" FontSize="11"/>
<Polygon Points="0,0 0,15 15,15 15,0"
Stroke="{Binding Fill}"
StrokeThickness="5">
</Polygon>
</StackPanel>
</ControlTemplate>
</Fluent:DropDownButton.Template>
<ColorSelectorModule:ColorGallery/>
</Fluent:DropDownButton>
P.S.:我知道这是针对特定库控件的问题。但是,我在该项目的论坛上没有得到任何回应。
进一步解释 Fluent:DropDownButton 的属性: 按钮的内容(Fluent:DropDownButton-Tags 之间的代码)并不能确定按钮中的内容,而是确定按钮的 DropDownMenu 中显示的内容。这就是为什么我必须修改按钮本身的内容(单击以激活 DrowDownMenu 的区域)。
我在这里尝试编写的是 FontColor-Button,其行为类似于 Word-FontColor-Button,您可以在其中看到按钮内的条中的当前颜色。
对于任何感兴趣的人,这里有一个指向我在 Fluent 项目页面上的解决方案的链接:http://fluent.codeplex.com/Thread/View.aspx?ThreadId=221817
【问题讨论】:
标签: wpf overriding styles controltemplate