zoukankan      html  css  js  c++  java
  • ControlTemplate in WPF —— Slider

    <!--Slider 样式-->
                <Style x:Key="StyleForRepeatButton" TargetType="{x:Type RepeatButton}">
                    <Style.Setters>
                        <Setter Property="Background">
                            <Setter.Value>
                                <LinearGradientBrush  
                                StartPoint="0.5,0"  
                                EndPoint="0.5,1">
                                    <GradientStop Color="LightGreen" Offset="0"/>
                                    <GradientStop Color="Yellow" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Height" Value="10"/>
                        <Setter Property="BorderBrush" Value="Transparent"/>
                        <Setter Property="Focusable" Value="False"/>
                    </Style.Setters>
                    <Style.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush StartPoint="0.5,0"  
                                                     EndPoint="0.5,1">
                                        <GradientStop Color="LightBlue" Offset="0"/>
                                        <GradientStop Color="SkyBlue" Offset="1"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
                <ControlTemplate x:Key="tmpThumb" TargetType="{x:Type Thumb}">
                    <Ellipse Name="e" Width="13" MinHeight="20" Fill="Blue" Cursor="Hand"/>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="e" Property="Fill" Value="Red"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
                <ControlTemplate x:Key="tmpSlider" TargetType="{x:Type Slider}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto" MinHeight="25"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <TickBar x:Name="top" Fill="Magenta" Grid.Row="0" HorizontalAlignment="Stretch"  
                             Placement="Top" Height="8"  
                             Visibility="Collapsed"/>
                        <Track x:Name="PART_Track" Grid.Row="1" HorizontalAlignment="Stretch">
                            <Track.IncreaseRepeatButton>
                                <RepeatButton Style="{StaticResource StyleForRepeatButton}"  
                                          Command="Slider.IncreaseLarge"/>
                            </Track.IncreaseRepeatButton>
                            <Track.DecreaseRepeatButton>
                                <RepeatButton Style="{StaticResource StyleForRepeatButton}"  
                                          Command="Slider.DecreaseLarge"/>
                            </Track.DecreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Height="20" Template="{StaticResource tmpThumb}"/>
                            </Track.Thumb>
                        </Track>
                        <TickBar x:Name="Bottom" Grid.Row="2" Fill="Magenta" HorizontalAlignment="Stretch"  
                             Visibility="Collapsed" Placement="Bottom" Height="8"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TickPlacement" Value="TopLeft">
                            <Setter TargetName="top" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="BottomRight">
                            <Setter Property="Visibility" TargetName="Bottom" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="Both">
                            <Setter TargetName="top" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Bottom" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
  • 相关阅读:
    NSHashtable and NSMaptable
    架构的本质:构造定律与结合规则
    软件复用的基础和形式
    架构模式:循环模式、管道模式
    待整理
    functions and closures are reference types-函数和闭包是引用类型
    @autoclosure-可以让表达式自动封装成一个闭包:输入的是一个表达式
    Python 运算符优先级
    Linux下chkconfig命令详解
    Linux下Redis开机自启(Centos)
  • 原文地址:https://www.cnblogs.com/tianciliangen/p/7410714.html
Copyright © 2011-2022 走看看