Esempio n. 1
0
        private void Toggle()
        {
            var isOn = IsOn;

            IsOn = !isOn;

            // Request a play invoke sound
            ElementSoundPlayerService.RequestInteractionSoundForElementStatic(ElementSoundKind.Invoke, this);
        }
Esempio n. 2
0
        private protected virtual void OnClick()
        {
            // Request a play invoke sound for Click event. This call needs to be made before the click event is raised.
            // This is because RequestInteractionSoundForElement expects the element to be in the tree.
            // And some click handlers remove the button from the tree e.g. an accept/cancel button on a Popup or Flyout.
            ElementSoundPlayerService.RequestInteractionSoundForElementStatic(ElementSoundKind.Invoke, this);

            // Create the args
            var args = new RoutedEventArgs();

            args.OriginalSource = this;

            // Raise the event
            Click?.Invoke(this, args);

            // Execute command associated with the button
            ExecuteCommand();
        }