Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ObjectAnimationUsingKeyFrames to control an image slideshow
    primarykey
    data
    text
    <p>I'm trying to use an animation to control a slideshow of images.</p> <p>The user enters a folder path into txtaddress, clicks on btnGo and the program displays each image found in that folder for two seconds.</p> <p>However, I'm stuggling to control this using animations. When it begins the slideshow I get an error of "Cannot resolve all property references in the property path "imgMain.Source"</p> <p>My complete code is below. Any ideas?</p> <pre><code>Imports System.IO Imports System.Windows.Media.Animation Class MainWindow Private Property ImageSource As String Private Sub btnGo_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnGo.Click 'Get file list Dim fileList(0) As String Dim btm(0) As BitmapImage Dim dir1 As New DirectoryInfo(txtAddress.Text) Dim anim As New ObjectAnimationUsingKeyFrames For Each fi In dir1.GetFiles("*.bmp") fileList(UBound(fileList)) = fi.Name ReDim Preserve fileList(UBound(fileList) + 1) Next For Each fi In dir1.GetFiles("*.png") fileList(UBound(fileList)) = fi.Name ReDim Preserve fileList(UBound(fileList) + 1) Next For Each fi In dir1.GetFiles("*.jpg") fileList(UBound(fileList)) = fi.Name ReDim Preserve fileList(UBound(fileList) + 1) Next 'Create animation anim.Duration = TimeSpan.FromSeconds(UBound(fileList) * 2) Dim idx As Integer For idx = 0 To UBound(fileList) - 1 btm(idx) = New BitmapImage(New Uri(txtAddress.Text &amp; "\" &amp; fileList(idx), UriKind.Absolute)) anim.KeyFrames.Add(New DiscreteObjectKeyFrame(btm(idx), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(idx * 2)))) ReDim Preserve btm(UBound(btm) + 1) Next Dim sBoard As New Storyboard sBoard.Children.Add(anim) Storyboard.SetTargetName(anim, imgMain.Name) Storyboard.SetTargetProperty(anim, New PropertyPath("imgMain.Source")) sBoard.Begin(Me) End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload