In a custom control, how to get the slider value while it is being animated?
up vote
0
down vote
favorite
WPF
The Storyboard will advance the slider. I need to get the current numerical value of the slider as the storyboard moves. This seems to be difficult.
This is the code I would LIKE to have, BUT VALUE IS NOT ACCESSIBLE.
My question, how can I get the actual slider value while it is being animated???
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>
Here is the XAML (with much removed):
<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>
wpf animation storyboard slider custom-controls
add a comment |
up vote
0
down vote
favorite
WPF
The Storyboard will advance the slider. I need to get the current numerical value of the slider as the storyboard moves. This seems to be difficult.
This is the code I would LIKE to have, BUT VALUE IS NOT ACCESSIBLE.
My question, how can I get the actual slider value while it is being animated???
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>
Here is the XAML (with much removed):
<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>
wpf animation storyboard slider custom-controls
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
WPF
The Storyboard will advance the slider. I need to get the current numerical value of the slider as the storyboard moves. This seems to be difficult.
This is the code I would LIKE to have, BUT VALUE IS NOT ACCESSIBLE.
My question, how can I get the actual slider value while it is being animated???
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>
Here is the XAML (with much removed):
<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>
wpf animation storyboard slider custom-controls
WPF
The Storyboard will advance the slider. I need to get the current numerical value of the slider as the storyboard moves. This seems to be difficult.
This is the code I would LIKE to have, BUT VALUE IS NOT ACCESSIBLE.
My question, how can I get the actual slider value while it is being animated???
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>
Here is the XAML (with much removed):
<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>
wpf animation storyboard slider custom-controls
wpf animation storyboard slider custom-controls
asked Nov 11 at 5:04
Alan Wayne
1,57512251
1,57512251
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245996%2fin-a-custom-control-how-to-get-the-slider-value-while-it-is-being-animated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown