问题
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