Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions WinUIGallery/ControlPages/SoundPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.On
</local:ControlExample.CSharp>
</local:ControlExample>
<local:ControlExample x:Name="Example3" HeaderText="Play Specific System Sound">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Play Sound" ElementSoundMode="Off" Click="Button_Click" HorizontalAlignment="Left"/>
<ComboBox x:Name="soundSelection" Grid.Column="1" Header="Pick Custom Sound" SelectedIndex="1" HorizontalAlignment="Right" Margin="50,0,0,0">
<ComboBoxItem>Focus</ComboBoxItem>
<ComboBoxItem>Invoke</ComboBoxItem>
<ComboBoxItem>Show</ComboBoxItem>
<ComboBoxItem>Hide</ComboBoxItem>
<ComboBoxItem>MoveNext</ComboBoxItem>
<ComboBoxItem>MovePrevious</ComboBoxItem>
<ComboBoxItem>GoBack</ComboBoxItem>
</ComboBox>
</Grid>
<StackPanel Orientation="Vertical" Spacing="5">
<Button Content="&#x25B6; Focus" ElementSoundMode="Off" Tag="0" Click="Button_Click"/>
<Button Content="&#x25B6; Invoke" ElementSoundMode="Off" Tag="1" Click="Button_Click"/>
<Button Content="&#x25B6; Show" ElementSoundMode="Off" Tag="2" Click="Button_Click"/>
<Button Content="&#x25B6; Hide" ElementSoundMode="Off" Tag="3" Click="Button_Click"/>
<Button Content="&#x25B6; MovePrevious" ElementSoundMode="Off" Tag="4" Click="Button_Click"/>
<Button Content="&#x25B6; MoveNext" ElementSoundMode="Off" Tag="5" Click="Button_Click"/>
<Button Content="&#x25B6; GoBack" ElementSoundMode="Off" Tag="6" Click="Button_Click"/>
</StackPanel>

<local:ControlExample.CSharp>
<x:String xml:space="preserve">
ElementSoundPlayer.State = ElementSoundPlayerState.On;
Expand All @@ -62,8 +56,8 @@ ElementSoundPlayer.Play(ElementSoundKind.Focus);
ElementSoundPlayer.Play(ElementSoundKind.Invoke);
ElementSoundPlayer.Play(ElementSoundKind.Show);
ElementSoundPlayer.Play(ElementSoundKind.Hide);
ElementSoundPlayer.Play(ElementSoundKind.MoveNext);
ElementSoundPlayer.Play(ElementSoundKind.MovePrevious);
ElementSoundPlayer.Play(ElementSoundKind.MoveNext);
ElementSoundPlayer.Play(ElementSoundKind.GoBack);
</x:String>
</local:ControlExample.CSharp>
Expand Down
7 changes: 4 additions & 3 deletions WinUIGallery/ControlPages/SoundPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -28,8 +28,9 @@ public SoundPage()
}

private void Button_Click(object sender, RoutedEventArgs e)
{
ElementSoundPlayer.Play((ElementSoundKind)soundSelection.SelectedIndex);
{
var tagInt = int.Parse((string)(sender as Button).Tag);
ElementSoundPlayer.Play((ElementSoundKind)tagInt);
}

private void spatialAudioBox_Checked(object sender, RoutedEventArgs e)
Expand Down