Silverlight: Accordion: alter arrow color in code or binding

本小妞迷上赌 提交于 2019-12-24 00:02:22

问题


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.

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>

回答1:


You can copy the template into your project and modify the Fill property so it's bound to the template fill:

Fill="{TemplateBinding 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.



来源:https://stackoverflow.com/questions/7032969/silverlight-accordion-alter-arrow-color-in-code-or-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!