Silverlight:手风琴:更改代码或绑定中的箭头颜色 [英] Silverlight: Accordion: alter arrow color in code or binding
问题描述
我想通过根据一些数据提供的标准为手风琴标题按钮的箭头着色(随着时间的推移从明亮到暗淡).
I'd like to style the accordion header button's arrow by coloring it per some data provided criteria (aging it from bright to dull over time).
我已经深入研究了手风琴按钮的模板并调整了各种模板样式,但我没有看到任何方法可以通过某种方式暴露箭头填充或箭头笔触,这将允许我绑定颜色、绑定和使用转换器以通过可视化树更改颜色或访问代码中的箭头.
I've delved into the accordion button's template and tuned various template styles, but I do not see any way to expose the arrow Fill or arrow Stroke through some means which will allow me to either bind the colors, bind and use a Converter to alter the colors, or access the arrow in code, through the visual tree.
这些方法中的任何一种都适合我.
Any of these methods would be fine for me.
这是 AccordionButton 模板中的箭头样式:
Here's the arrow's style from the AccordionButton template:
<Path x:Name="arrow"
StrokeThickness=".5"
Margin="7.975,4.627,5.975,6.627"
RenderTransformOrigin="0.5,0.5"
Data="[snip]"
UseLayoutRounding="False"
Stroke="Black"
Fill="Black" d:LayoutOverrides="Width, Height">
</Path>
推荐答案
您可以将模板复制到您的项目中并修改 Fill 属性,使其绑定到模板 fill:
You can copy the template into your project and modify the Fill property so it's bound to the template fill:
Fill="{TemplateBinding Fill}"
然后在 xaml 中,当您定义手风琴时,将控件模板设置为您的自定义模板.然后,您可以使用绑定或隐藏的代码更改手风琴的 Fill 属性.
Then in xaml, when you define the accordion, set the control template to your custom one. You can then change the accordion's Fill property with a binding or in code behind.
这篇关于Silverlight:手风琴:更改代码或绑定中的箭头颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!