vb.net - WPF MediaElement opacity does not fade in gradually after changing source -
i have wpf digital signage application displays slideshow of images and/or videos. i'm using single mediaelement object , transition handled storyboard animations of opacity property.
the image fades out smoothly, fade in doesn't. opacity appears stay @ 0 length of animation duration, , go 1 in 1 go.
private function getfadeinstory() storyboard dim story new storyboard dim fadeinanimation new doubleanimation { .begintime = new timespan(0), .from = 0, .to = 1, .duration = timespan.frommilliseconds(my.settings.fadeinduration)} storyboard.settargetproperty(fadeinanimation, new propertypath(uielement.opacityproperty)) story.children.add(fadeinanimation) return story end function private function getfadeoutstory() storyboard dim story new storyboard dim fadeoutanimation new doubleanimation { .begintime = new timespan(0), .to = 0, .from = 1, .duration = timespan.frommilliseconds(my.settings.fadeoutduration)} storyboard.settargetproperty(fadeoutanimation, new propertypath(uielement.opacityproperty)) story.children.add(fadeoutanimation) return story end function private sub displayslideimage() dim slideuri uri = getnextslidepath() dim s storyboard = getfadeoutstory() addhandler s.completed, sub() finishedfadeout(slideuri) storyboard.settarget(s, mediaelement) s.begin() end sub private sub finishedfadeout(slideuri uri) mediaelement.source = slideuri dim s storyboard = getfadeinstory() storyboard.settarget(s, mediaelement) s.begin() end sub
however, if mediaelement.source property not change, fade in , fade out work expected. i've tried without success:
- wrapping mediaelement.source change in begininit / endinit statements
- calling mediaelement.upatelayout after changing source
- recreating mediaelement object every slide
any ideas?
Comments
Post a Comment