Click Sound
The keyboard comes with a click sound on key press.
To disable the click sound, set the IsKeyPressSoundEnabled property to False.
Disabling click sound
<telerik:RadVirtualKeyboard IsKeyPressSoundEnabled="False" />
The sound player that plays the sounds can be accessed or replaced using the KeySoundPlayer property of RadVirtualKeyboard.
Using Custom Sound File
To replace the default click sound, initialize a new DefaultKeySoundPlayer and provide it with a Stream containing a sound file information.
Setting custom sound file
StreamResourceInfo info = Application.GetResourceStream(new Uri(@"/WpfApplication;component/myClickSoundFile.wav", UriKind.Relative));
virtualKeyboard.KeySoundPlayer = new DefaultKeySoundPlayer(info.Stream);
The DefaultKeySoundPlayer uses the .NET native SoundPlayer class to playback .wav files.
Creating Custom Sound Player
The sound playback implementation can be fully replaced by implementing the sound player from scratch. To do so, implement the IKeySoundPlayer interface. The following example shows how to implement a very basic key sound player that uses the SystemSounds.Beep sound.
Implementing custom key sound player
public class CustomKeySoundPlayer : IKeySoundPlayer
{
public bool IsSoundEnabled { get; set; }
public void Play(BaseKeyViewModel viewModel)
{
if (IsSoundEnabled)
{
SystemSounds.Beep.Play();
}
}
}
Assigning the custom key sound player
public Example()
{
InitializeComponent();
this.virtualKeyboard.KeySoundPlayer = new CustomKeySoundPlayer();
}