0
我有一個滾動條來改變它的值,並且我想寫一個Label
每時每刻都在做的值。如何將滾動值綁定到WPF中的標籤?
我曾嘗試這樣的:
<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>
我已經改變滑塊內容的外觀,以一個橢圓形的滑動件(如果有人感到好奇我可以附加全碼)。
但我的問題與我的標籤一致。當我更改滾動值時,我希望它改變。現在它顯示第一個值,但疊加滾動(我無法滾動)並且無法更改其值。
任何想法我做錯了,將滾動值綁定到標籤內容?