【问题标题】:Override ControlTemplate - not Style覆盖 ControlTemplate - 不是样式
【发布时间】:2010-08-03 10:00:50
【问题描述】:

我正在覆盖 ButtonContent。我的问题是,当我这样做时,按钮的默认 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


    【解决方案1】:

    您只是更改了模板,模板定义了您所说的行为而不是样式,没有模板继承,因此您必须手动复制旧模板中的所有行为

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 2021-11-21
    • 1970-01-01
    相关资源
    最近更新 更多