zoukankan
html css js c++ java
继续聊WPF——自定义滚动条
关键点:Track控件没有默认模板,它包括三个部分
DecreaseRepeatButton——这是一个RepeatButton即滑块左(上)的部分;
IncreaseRepeatButton——同上,即滑块右(下)部分;
Thumb——很明显了,这是拖动的滑块,请参考前面的文章。
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.Resources> <ControlTemplate x:Key="myThumb" TargetType="{x:Type Thumb}"> <Border Name="bd" BorderThickness="0.8" CornerRadius="2" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" Margin="0,1,0,1"> <Border.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="#112299" Offset="0"/> <GradientStop Color="#3522AA" Offset="1"/> </LinearGradientBrush> </Border.Background> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.Setters> <Setter TargetName="bd" Property="BorderBrush" Value="#66BBEE"/> </Trigger.Setters> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> <ControlTemplate x:Key="myRepBt" TargetType="{x:Type RepeatButton}"> <Border Margin="0,2,0,2" BorderThickness="0.7" BorderBrush="#BBBBBB"> <Border.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="White" Offset="0"/> <GradientStop Color="LightGray" Offset="1"/> </LinearGradientBrush> </Border.Background> </Border> </ControlTemplate> <ControlTemplate x:Key="rbtForScrollBar" TargetType="{x:Type RepeatButton}"> <Border CornerRadius="2" Margin="0,1,0,1"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> <GradientStop Color="Yellow" Offset="0"/> <GradientStop Color="Orange" Offset="1"/> </LinearGradientBrush> </Border.Background> <Path VerticalAlignment="Center" HorizontalAlignment="Center" Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" Fill="Black"/> </Border> </ControlTemplate> <ControlTemplate x:Key="ScrollTmp" TargetType="{x:Type ScrollBar}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition MaxWidth="20"/> <ColumnDefinition Width="*"/> <ColumnDefinition MaxWidth="20"/> </Grid.ColumnDefinitions> <Border Grid.ColumnSpan="3" /> <RepeatButton Template="{StaticResource rbtForScrollBar}" Grid.Column="0" Margin="0,1,0,1" Command="ScrollBar.LineLeftCommand" Content="M0,4 L4,8 L4,0 Z"/> <Track Grid.Column="1" Name="PART_Track" Maximum="{TemplateBinding Maximum}" Minimum="{TemplateBinding Minimum}" Value="{TemplateBinding Value}"> <Track.DecreaseRepeatButton> <RepeatButton Template="{StaticResource myRepBt}" Command="ScrollBar.PageLeftCommand"/> </Track.DecreaseRepeatButton> <Track.IncreaseRepeatButton> <RepeatButton Template="{StaticResource myRepBt}" Command="ScrollBar.PageRightCommand"/> </Track.IncreaseRepeatButton> <Track.Thumb> <Thumb Width="auto" Template="{StaticResource myThumb}"/> </Track.Thumb> </Track> <RepeatButton Template="{StaticResource rbtForScrollBar}" Grid.Column="3" Margin="0,1,0,1" Command="ScrollBar.LineRightCommand" Content="M0,0 L0,8 4,4 Z"/> </Grid> </ControlTemplate> </Window.Resources> <Canvas Margin="10,10,10,10"> <ScrollBar Canvas.Left="5" Canvas.Top="5" Width="260" Height="28" Template="{StaticResource ScrollTmp}" Orientation="Horizontal" Maximum="5" Minimum="0"/> </Canvas> </Window>
查看全文
相关阅读:
对于java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I错误解决
attempted to assign id from null one-to-one
The class has no identifier property
javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z
final和static
hibernate事务
log4j:WARN Please initialize the log4j system properly.解决
用最有效率的方法算出2乘以8等於几
char型变量中能存贮一个中文汉字
基本数据类型范围
原文地址:https://www.cnblogs.com/javawebsoa/p/2457970.html
最新文章
Oracle问题手册收录一
oracle实现查找子字符串在字符串中的个数函数
oracle_单引号转义
4- Java运算符优先级
SVN各种图标总结
css的text-overflow与vertical-align与div水平居中
webStrom的快捷键
SQL Server 批量插入数据的两种方法
解决 Unable to load native-hadoop library for your platform
ETL利器Kettle实战应用解析系列一【Kettle使用介绍】
热门文章
MySQL中函数CONCAT及GROUP_CONCAT
SQL SERVER 日志已满的处理方法 (转)
Https系列之三:让服务器同时支持http、https,基于spring boot
java 基础
从事件总线和消息队列说起
linux awk命令详解
WEB项目web.xml文件中classpath: 跟classpath*:使用的区别
图片按钮提交表单
javascript键盘输入控制
java连接sql server2000/2005
Copyright © 2011-2022 走看看