Hi.
I have XAML code in which a stack panel that contains a media-element and a button is defined. Whenever the button is clicked, some sound is made. Here's the relevant portion:
<StackPanel Name="spPanel" Orientation="Horizontal">
<MediaElement Name="mediaelementButtonInstructions" />
<Button Name="buttonNew" Command="New" Width="Auto" Height="Auto" Content="_New">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.IsPressed">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Source="Resources/Sound_ButtonNew.mp3" Storyboard.TargetName="mediaelementButtonInstructions" BeginTime="0:0:0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
</StackPanel>
That's working as expected.
Now I want do add more buttons, where each button uses a MP3 of its own. Besides, I want to avoid replicating the whole <Button>...</Button> section for each button. I tried to create a suitable resource (style, story-board, &c), but failed to find a way to specify for each button the name of its MP3 and the name of the media-element, and also failed to pass these to the that resource as parameters.
Does anybody know how may I achieve these goals?
Thanks,
Ofer