在代码或绑定中更改箭头颜色

在代码或绑定中更改箭头颜色

本文介绍了Silverlight:Accordion:在代码或绑定中更改箭头颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我希望通过按照一些数据提供的标准来对手风琴头按钮的箭头进行着色。 ve深入手风琴按钮的模板和调整各种模板样式,但我没有看到任何方式暴露箭头填充或箭头冲程通过一些手段,这将允许我绑定的颜色,绑定和使用转换器来改变颜色,或者通过可视树访问代码中的箭头。



这些方法对我来说都不错。



以下是AccordionButton模板中的箭头样式:

 路径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 =Blackd:LayoutOverrides =Width,Height>
< / Path>


解决方案

您可以将模板复制到项目中, Fill属性,因此它绑定到模板填充:

  Fill ={TemplateBinding Fill}

然后在xaml中,当定义手风琴时,将控件模板设置为自定义模板。
然后可以用绑定或代码在后面更改手风琴的Fill属性。


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>
解决方案

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.

这篇关于Silverlight:Accordion:在代码或绑定中更改箭头颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:52