如何自定义ToggleSwitch控件样式(转)

打开Toolkit源码中的Generic.xaml文件可以看到其默认样式,发现接结构组成元素为:

  1. ToggleSwitch

    其中,ToggleSwitch又由以下几个部分组成:

    • Header
    • Content
    • ToogleSwitchButton
  2. ToogleSwitchButton

    ToggleSwitchButton由以若干个Grid和Boder组成,它们分别是:

    • Grid:SwitchRoot
    • Grid:SwitchTrack
    • Grid:SwitchBottom
    • Rectangle:SwitchBackground(包含两个Border,A和B)
    • Border:SwitchThumb
    • Border:ThumbCenter

我们可以设置其各个元素显示不同的颜色,例如将各元素设为以下颜色:

  • Header.ForeGround – Blue
  • Content.ForeGround — Brown
  • ToggleSwitch.SwitchForeGround —Orange
  • SwitchRoot.Background — Black
  • SwitchTrack.Background — Green
  • SwitchBottom.Background — Green
  • SwitchBackground.BoderA.BorderBrush — Red
  • SwitchBackground.BoderA.BorderBrush — White
  • SwitchThumb.BorderBrush — Gold
  • ThumbCenter.BorderBrush — Aqua
  • ThumbCenter.Background — Chocolate
posted @ 2012-06-11 11:59  博琼  阅读(1038)  评论(0编辑  收藏  举报