예제 #1
0
        private void Label_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key != Windows.System.VirtualKey.Enter)
            {
                return;
            }

            var button = this.Descendants <Button>().FirstOrDefault(x => x is Button btn && string.Equals(btn.Name, "PrimaryButton"));

            if (button == null)
            {
                return;
            }

            var peer    = ButtonAutomationPeer.CreatePeerForElement(button as Button);
            var pattern = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            pattern.Invoke();
        }