您好,登錄后才能下訂單哦!
?? WPF中Slider分為三部分,滑塊類型為Thumb;進度條類型為RepeatButton,其中:位于滑塊左側或下側部分為DecreaseRepeatButton,位于滑塊右側或上側部分為IncreaseRepeatButton。
?? 設置Slider樣式時,一般單獨設置三部分的樣式(Style),然后在Sldier的樣式(Style)中引用它們。
<Style TargetType="{x:Type Thumb}" x:Key="SliderThumbStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Ellipse Width="25" Height="25" Fill="Black"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="RepeatButton" x:Key="Slider_DecreaseRepeatBtnStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border SnapsToDevicePixels="True" Background="DeepSkyBlue" BorderThickness="1"
CornerRadius="5" BorderBrush="DeepSkyBlue" Height="10"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Slider}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
<Grid>
<Border Name="PART_Border" BorderBrush="Black" BorderThickness="1" CornerRadius="5"
Padding="2" Width="{TemplateBinding Width}" Height="10" Background="LightGray"
HorizontalAlignment="Stretch" VerticalAlignment="Center">
</Border>
<Track Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource Slider_DecreaseRepeatBtnStyle}">
</RepeatButton>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource SliderThumbStyle}" />
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。