wpf - SliderThumbStyle 内的文本
问题描述
所以这是我的SliderThumbStyle
Style
:
<Style x:Key="SliderThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Grid>
<Border Name="outerBorder"
Background="{DynamicResource LabelDisableForegroundColor}"
BorderBrush="{DynamicResource LabelDisableForegroundColor}"
Height="20"
Width="20"
Opacity="1"
BorderThickness="2"
CornerRadius="8"/>
<TextBlock x:Name="sliderValue"
FontSize="11"
Foreground="Silver"
Text="{Binding }"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
正如你所看到的,我在里面放了Thumb
一个简单TextBlock
的 in oder 来查看当前Slider value
我需要在 Text 中输入的内容property
:
Text="{Binding }"
解决方案
Thumb
如果是 的视觉子级,这应该可以工作Slider
:
<TextBlock Text="{Binding Value, RelativeSource={RelativeSource AncestorType=Slider}}" />
推荐阅读
- reactjs - 有什么方法可以调用 api 并在 reactjs 中使用 useState 保存它?
- python - 设置一个数据框来测量肿瘤体积
- python - 滚动上下文超时 [Elasticsearch 5.6.7]
- javascript - 404 的随机图像
- arrays - 如何在javascript中复制数组值
- forms - 如何在颤振中获取表单变量
- c++ - 无法从 qt 中的 SQLITE 检索数据
- javascript - 将时间戳列表排序到另一个列表
- multicast - Zerotier 使用多播
- haskell - Haskell 函数,它接受一个元素列表,如果列表包含重复项,则返回 true,否则返回