我有一个改变它的价值的卷轴,我想写一个Label
每时每刻都在使用的价值。
我试过这个:
<Window x:Class="WpfApplication16.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:WpfApplication16"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<my:ValueAngleConverter x:Key="valueAngleConverter"/>
<my:ValueTextConverter x:Key="valueTextConverter"/>
</Window.Resources>
<Grid>
<Slider Name="knob" SmallChange="1">
<Slider.Template>
<ControlTemplate>
<Viewbox>
<Canvas Width="300" Height="300" Margin="5">
<Ellipse Fill="LightBlue" Width="300" Height="300" Canvas.Left="0" Canvas.Top="0"
Stroke="Black" StrokeThickness="10"
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
MouseMove="Ellipse_MouseMove"/>
<Ellipse Fill="Black" Width="60" Height="60" Canvas.Left="120" Canvas.Top="120"/>
<Canvas>
<Line Stroke="Red" StrokeThickness="5" X1="150" Y1="30" X2="150" Y2="20"
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"/>
<Canvas.RenderTransform>
<RotateTransform CenterX="150" CenterY="150">
<RotateTransform.Angle>
<MultiBinding Converter="{StaticResource valueAngleConverter}">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum"/>
</MultiBinding>
</RotateTransform.Angle>
</RotateTransform>
</Canvas.RenderTransform>
</Canvas>
</Canvas>
</Viewbox>
</ControlTemplate>
</Slider.Template>
</Slider>
<Label Content="{Binding Value, ElementName=knob, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
我已将滑块内容的外观更改为椭圆滑块(如果有人感到好奇,我可以附上完整代码)。
但我的问题与我的标签有关。当我改变滚动值时,我希望它改变。现在它显示第一个值,但堆叠滚动(我无法滚动)并且无法更改其值。
关于将滚动值绑定到标签内容我做错了什么的任何想法?