WPF
情节提要将使滑块前进。随着情节提要板的移动,我需要获取滑块的当前数值。这似乎很困难。
这是我想要的代码,但是无法获取值。
我的问题是,如何在动画化时获得滑块的实际值?
TIA
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard Duration="0:0:10">
<DoubleAnimation Storyboard.TargetProperty="(RangeBase.Value)"
Storyboard.TargetName="PART_RecordingProgressBar"
From="{Binding ElementName=PART_RecordingProgressBar, Path=Value, Mode=OneWay}"
To="{Binding ElementName=PART_RecordingProgressBar, Path=Maximum, Mode=OneWay}"
FillBehavior="HoldEnd"
***THIS FAILS! **** Value ="{Binding Path= CurrentValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWayToSource}"
>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
以下是XAML(已删除的内容):
<Style TargetType="{x:Type local:AudioRecorder}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:AudioRecorder}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<StackPanel Orientation="Horizontal">
<Button x:Name="FastForward" Height="20">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border>
<Viewbox Stretch="Fill">
<Path Stroke="Black" Data=" F1
M 0 0 V40 L 34.6 20 Z
M 17.3 0 V40 L 51.9 20 Z" Fill="LightBlue" />
</Viewbox>
</Border>
</ControlTemplate>
</Button.Template>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard Duration="0:0:10">
<DoubleAnimation Storyboard.TargetProperty="(RangeBase.Value)"
Storyboard.TargetName="PART_RecordingProgressBar"
From="{Binding ElementName=PART_RecordingProgressBar, Path=Value, Mode=OneWay}"
To="{Binding ElementName=PART_RecordingProgressBar, Path=Maximum, Mode=OneWay}"
FillBehavior="HoldEnd"
Value ="{Binding Path= CurrentValue, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWayToSource}"
>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<Popup Name="Popup"
Placement="Bottom" PlacementTarget="{Binding ElementName=OpenRecorder}"
AllowsTransparency="True" Focusable="False" StaysOpen="True" IsOpen="False" PopupAnimation="None">
<Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}">
<Slider x:Name="PART_RecordingProgressBar"
IsMoveToPointEnabled="True"
Maximum="{Binding Path=CurrentTrackLength, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Value="{Binding Path=CurrentTrackPosition, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
HorizontalAlignment="Left" Height="22" Margin="15,423,0,0" VerticalAlignment="Top" Width="375" />
</Grid>
</Border>
<Button Name="closeButton" Content="Exit" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="73"/>
</Grid>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>