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>









share|improve this question


























    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>









    share|improve this question
























      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>









      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 5:04









      Alan Wayne

      1,57512251




      1,57512251





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine