事件处理程序内的代码隐藏内联
此 xaml 指向 Completed 事件中的事件处理程序成员函数:
<Storyboard x:Name="myStory" Completed="myStoryCompleted" FillBehavior="Stop">
<!-- storyboard things -->
</Storyboard>
在我的情况下,我只想在 Storyboard 结束时播放简单的声音(不知道如何在 Storyboard 中包含声音!),我会喜欢在 Completed 中包含“内联代码隐藏”...如果可能的话。是吗?像这样的东西:
<Storyboard x:Name="myStory" Completed="{mysound.Play();}" FillBehavior="Stop">
<!-- storyboard things -->
</Storyboard>
<MediaElement x:Name="mysound" Source="/mysound.mp3" Volume="100" />
This xaml points to an event handler member function in the Completed event:
<Storyboard x:Name="myStory" Completed="myStoryCompleted" FillBehavior="Stop">
<!-- storyboard things -->
</Storyboard>
As in my case I just want to play a simple sound when the Storyboard ends (don't know of a way to include sounds in a Storyboard!), I'd like to have "inline codebehind" in that Completed... if it's possible. Is it? Something like this:
<Storyboard x:Name="myStory" Completed="{mysound.Play();}" FillBehavior="Stop">
<!-- storyboard things -->
</Storyboard>
<MediaElement x:Name="mysound" Source="/mysound.mp3" Volume="100" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能在代码后面启动声音吗?
Can you not just start thesound in code behind?
看来终究是不可能的。 :-P
Seems not possible after all. :-P