首页 新闻 会员 周边

WPF微软有滑板控件吗

0
悬赏园豆:30 [已关闭问题]

WPF微软出了滑板控件吗

我找到的都是第三方的控件,需要收费,很不爽

有高手提供个免费的滑板控件吗?

问题补充: 滑板也叫滑动面板 求求高手指点下 有这方面的资料 给我说下
毛豆逗的主页 毛豆逗 | 初学一级 | 园豆:110
提问于:2009-09-07 10:08
< >
分享
所有回答(1)
0
  1 <ResourceDictionary>
2 <SolidColorBrush x:Key="NormalBrush" Color="#FFCCCCCC"/>
3
4 <SolidColorBrush x:Key="PressedBrush" Color="#FFEEEEEE"/>
5
6 <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888"/>
7
8 <!-- Border Brushes -->
9
10 <LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
11 <GradientBrush.GradientStops>
12 <GradientStopCollection>
13 <GradientStop Color="#CCC" Offset="0.0"/>
14 <GradientStop Color="#444" Offset="1.0"/>
15 </GradientStopCollection>
16 </GradientBrush.GradientStops>
17 </LinearGradientBrush>
18
19 <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
20 <Setter Property="SnapsToDevicePixels" Value="True"/>
21 <Setter Property="OverridesDefaultStyle" Value="true"/>
22 <Setter Property="Focusable" Value="false"/>
23 <Setter Property="Template">
24 <Setter.Value>
25 <ControlTemplate TargetType="{x:Type RepeatButton}">
26 <Border Name="Border" CornerRadius="2" Background="{StaticResource NormalBrush}"
27 BorderBrush="{StaticResource NormalBorderBrush}">
28 <Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="White"
29 Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
30 Opacity="{Binding Path=Opacity, RelativeSource={RelativeSource TemplatedParent}}"/>
31 </Border>
32 <ControlTemplate.Triggers>
33 <Trigger Property="IsPressed" Value="true">
34 <Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}"/>
35 </Trigger>
36 <Trigger Property="IsEnabled" Value="false">
37 <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
38 </Trigger>
39 </ControlTemplate.Triggers>
40 </ControlTemplate>
41 </Setter.Value>
42 </Setter>
43 </Style>
44
45 <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
46 <Setter Property="SnapsToDevicePixels" Value="True"/>
47 <Setter Property="OverridesDefaultStyle" Value="true"/>
48 <Setter Property="IsTabStop" Value="false"/>
49 <Setter Property="Focusable" Value="false"/>
50 <Setter Property="Template">
51 <Setter.Value>
52 <ControlTemplate TargetType="{x:Type RepeatButton}">
53 </ControlTemplate>
54 </Setter.Value>
55 </Setter>
56 </Style>
57
58 <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
59 <Setter Property="SnapsToDevicePixels" Value="True"/>
60 <Setter Property="OverridesDefaultStyle" Value="true"/>
61 <Setter Property="IsTabStop" Value="false"/>
62 <Setter Property="Focusable" Value="false"/>
63 <Setter Property="Template">
64 <Setter.Value>
65 <ControlTemplate TargetType="{x:Type Thumb}">
66 <Border CornerRadius="2" Background="{TemplateBinding Background}"
67 BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"/>
68 </ControlTemplate>
69 </Setter.Value>
70 </Setter>
71 </Style>
72
73 <Style x:Key="CustomListBoxItem" TargetType="{x:Type ListBoxItem}">
74 <Setter Property="SnapsToDevicePixels" Value="true"/>
75 <Setter Property="OverridesDefaultStyle" Value="true"/>
76 <Setter Property="Template">
77 <Setter.Value>
78 <ControlTemplate TargetType="ListBoxItem">
79 <Border Name="Border" Padding="1" SnapsToDevicePixels="true">
80 <ContentPresenter />
81 </Border>
82 </ControlTemplate>
83 </Setter.Value>
84 </Setter>
85 </Style>
86
87 <!--listBoxWithAutoScroll_Horizontal-->
88 <Style x:Key="ListBoxWithAutoScroll_Horizontal" TargetType="{x:Type ListBox}">
89 <Setter Property="SnapsToDevicePixels" Value="true"/>
90 <Setter Property="OverridesDefaultStyle" Value="true"/>
91 <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
92 <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
93 <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
94 <Setter Property="Background" Value="Transparent"/>
95 <Setter Property="ItemContainerStyle" Value="{StaticResource CustomListBoxItem}"/>
96 <Setter Property="Template">
97 <Setter.Value >
98 <ControlTemplate>
99 <Grid >
100 <ScrollViewer x:Name="scrollviewer">
101 <ScrollViewer.Template>
102 <ControlTemplate TargetType="{x:Type ScrollViewer}">
103 <Grid>
104 <ScrollBar x:Name="PART_HorizontalScrollBar" Orientation="Horizontal"
105 Value="{TemplateBinding HorizontalOffset}"
106 Maximum="{TemplateBinding ScrollableWidth}"
107 ViewportSize="{TemplateBinding ViewportWidth}"
108 Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
109 Height="{Binding Height, ElementName=Panel}">
110 <ScrollBar.Template>
111 <ControlTemplate>
112 <Track x:Name="PART_Track">
113 <Track.DecreaseRepeatButton>
114 <RepeatButton Command="ScrollBar.PageLeftCommand"
115 Style="{StaticResource ScrollBarPageButton}"/>
116 </Track.DecreaseRepeatButton>
117 <Track.IncreaseRepeatButton>
118 <RepeatButton Command="ScrollBar.PageRightCommand"
119 Style="{StaticResource ScrollBarPageButton}"/>
120 </Track.IncreaseRepeatButton>
121 <Track.Thumb>
122 <Thumb Style="{StaticResource ScrollBarThumb}" Opacity="0.8" Margin="0,-1"/>
123 </Track.Thumb>
124 </Track>
125 </ControlTemplate>
126 </ScrollBar.Template>
127 </ScrollBar>
128 <ScrollContentPresenter Margin="0,2" Height="Auto" VerticalAlignment="Center"/>
129 </Grid>
130 </ControlTemplate>
131 </ScrollViewer.Template>
132 <ItemsPresenter/>
133 </ScrollViewer>
134 <Grid x:Name="Panel" Margin="0,2">
135 <Grid.ColumnDefinitions>
136 <ColumnDefinition Width="Auto"/>
137 <ColumnDefinition Width="*"/>
138 <ColumnDefinition Width="Auto"/>
139 </Grid.ColumnDefinitions>
140 <RepeatButton x:Name="LineLeftButton" Grid.Column="0" Width="20" Opacity="0"
141 Style="{StaticResource ScrollBarLineButton}"
142 Content="M 8 0 L 8 32 L 0 16 Z"
143 Command="{x:Static ScrollBar.LineLeftCommand}"
144 CommandTarget="{Binding ElementName=scrollviewer}"
145 ClickMode="Hover"/>
146 <RepeatButton x:Name="LineRightButton" Grid.Column="2" Width="20" Opacity="0"
147 Style="{StaticResource ScrollBarLineButton}"
148 Content="M 0 0 L 8 16 L 0 32 Z"
149 Command="{x:Static ScrollBar.LineRightCommand}"
150 CommandTarget="{Binding ElementName=scrollviewer}"
151 ClickMode="Hover"/>
152 </Grid>
153 </Grid>
154 <ControlTemplate.Triggers>
155 <MultiTrigger>
156 <MultiTrigger.Conditions>
157 <Condition Property="IsMouseOver" Value="True"/>
158 </MultiTrigger.Conditions>
159 <MultiTrigger.EnterActions>
160 <BeginStoryboard>
161 <Storyboard>
162 <DoubleAnimation Storyboard.TargetName="LineLeftButton"
163 Storyboard.TargetProperty="Opacity" To="0.8" Duration="0:0:0.25"/>
164 <DoubleAnimation Storyboard.TargetName="LineRightButton"
165 Storyboard.TargetProperty="Opacity" To="0.8" Duration="0:0:0.25"/>
166 </Storyboard>
167 </BeginStoryboard>
168 </MultiTrigger.EnterActions>
169 <MultiTrigger.ExitActions>
170 <BeginStoryboard>
171 <Storyboard>
172 <DoubleAnimation Storyboard.TargetName="LineLeftButton"
173 Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25"/>
174 <DoubleAnimation Storyboard.TargetName="LineRightButton"
175 Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25"/>
176 </Storyboard>
177 </BeginStoryboard>
178 </MultiTrigger.ExitActions>
179 </MultiTrigger>
180 </ControlTemplate.Triggers>
181 </ControlTemplate>
182 </Setter.Value>
183 </Setter>
184 <Setter Property="ItemsPanel">
185 <Setter.Value >
186 <ItemsPanelTemplate>
187 <VirtualizingStackPanel Orientation="Horizontal"/>
188 </ItemsPanelTemplate>
189 </Setter.Value>
190 </Setter>
191 </Style>
192 <DataTemplate DataType="{x:Type Button}">
193 <Border x:Name="Border" BorderBrush="Black" BorderThickness="1" CornerRadius="4" Width="84" Height="68"
194 VerticalAlignment="Center" HorizontalAlignment="Center" Padding="1">
195 </Border>
196 <DataTemplate.Triggers>
197 <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}" Value="True">
198 </DataTrigger>
199 </DataTemplate.Triggers>
200 </DataTemplate>
201 <!--筹码滚动-->
202 </ResourceDictionary>
203 //上面是样式
204
205 <Grid>
206 <StackPanel>
207 <ListBox VerticalAlignment="Bottom" x:Name="horizontalSelectedItemsListBox" Height="100" Width="380"
208 Style="{StaticResource ListBoxWithAutoScroll_Horizontal}">
209 <Button Margin="0,15" Height="80" Width="80" Click="Button_Click"></Button>
210 <Button Margin="10,0" Height="80" Width="80"></Button>
211 <Button Margin="10,0" Height="80" Width="80"></Button>
212 <Button Margin="10,0" Height="80" Width="80"></Button>
213 <Button Margin="10,0" Height="80" Width="80"></Button>
214 <Button Margin="10,0" Height="80" Width="80"></Button>
215 <Button Margin="10,0" Height="80" Width="80"></Button>
216 <Button Margin="10,0" Height="80" Width="80"></Button>
217 <Button Margin="10,0" Height="80" Width="80"></Button>
218 <Button Margin="10,0" Height="80" Width="80"></Button>
219 </ListBox>
220 </StackPanel>
221 </Grid>

参考地址:http://www.codeproject.com/KB/WPF/AutoScrollListBox.aspx

上面代码是我自己删减过的,只需要更改ListBox中的Button就可以了

路晚歌 | 园豆:3 (初学一级) | 2012-03-28 10:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册