码迷,mamicode.com
首页 > 其他好文 > 详细

wpf iphone滑块样式CheckBox

时间:2014-05-10 08:19:52      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:style   tar   ext   color   c   http   

原文链接http://www.ilisen.net/iphone-slider-switch-style-checkbox.html
<!--CheckBox样式--> <Style x:Key="CheckRadioFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle Margin="14,0,0,0" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="SliderCheckBox" TargetType="{x:Type CheckBox}"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type CheckBox}"> <ControlTemplate.Resources> <Storyboard x:Key="StoryboardIsChecked"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="CheckFlag"> <EasingDoubleKeyFrame KeyTime="0" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="14"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="StoryboardIsCheckedOff"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="CheckFlag"> <EasingDoubleKeyFrame KeyTime="0" Value="14"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <BulletDecorator Background="Transparent" SnapsToDevicePixels="true"> <BulletDecorator.Bullet> <Border x:Name="ForegroundPanel" BorderThickness="1" Width="35" Height="20" CornerRadius="10"> <Canvas> <Border Background="White" x:Name="CheckFlag" CornerRadius="10" VerticalAlignment="Center" BorderThickness="1" Width="19" Height="18" RenderTransformOrigin="0.5,0.5"> <Border.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Border.RenderTransform> <Border.Effect> <DropShadowEffect ShadowDepth="1" Direction="180" /> </Border.Effect> </Border> </Canvas> </Border> </BulletDecorator.Bullet> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/> </BulletDecorator> <ControlTemplate.Triggers> <Trigger Property="HasContent" Value="true"> <Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/> <Setter Property="Padding" Value="4,0,0,0"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> </Trigger> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="ForegroundPanel" Property="Background" Value="Green" /> <Trigger.EnterActions> <BeginStoryboard x:Name="BeginStoryboardCheckedTrue" Storyboard="{StaticResource StoryboardIsChecked}" /> <RemoveStoryboard BeginStoryboardName="BeginStoryboardCheckedFalse" /> </Trigger.EnterActions> </Trigger> <Trigger Property="IsChecked" Value="False"> <Setter TargetName="ForegroundPanel" Property="Background" Value="Gray" /> <Trigger.EnterActions> <BeginStoryboard x:Name="BeginStoryboardCheckedFalse" Storyboard="{StaticResource StoryboardIsCheckedOff}" /> <RemoveStoryboard BeginStoryboardName="BeginStoryboardCheckedTrue" /> </Trigger.EnterActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> 使用: 1 <CheckBox Style="{DynamicResource SliderCheckBox}" Content="启动Windows时自动运行" IsChecked="{Binding WindowsAutomatically, Mode=TwoWay}" Margin="0,0,0,15"/>
http://www.ilisen.net/wp-content/uploads/2013/12/20131212144733.png

wpf iphone滑块样式CheckBox,布布扣,bubuko.com

wpf iphone滑块样式CheckBox

标签:style   tar   ext   color   c   http   

原文地址:http://www.cnblogs.com/ilisen/p/3719211.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!