AmazonScrape.MainWindow.dataGrid_MouseDoubleClick C# (CSharp) Method

dataGrid_MouseDoubleClick() private method

Double clicking a result item will attempt to open the item's URL in whatever program they have associated with URLs.
private dataGrid_MouseDoubleClick ( object sender, System.Windows.Input.MouseButtonEventArgs e ) : void
sender object
e System.Windows.Input.MouseButtonEventArgs
return void
        void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            // If the user is clicking the scrollbar (the arrow
            // or the "thumb"), don't attempt to open an item in the browser
            IInputElement element = e.MouseDevice.DirectlyOver;
            if (element != null && element is FrameworkElement)
            {
                var elementType = element.GetType();

                if (elementType == typeof(System.Windows.Controls.Primitives.RepeatButton) ||
                    elementType == typeof(System.Windows.Controls.Primitives.Thumb))
                { return; }
            }

            if (ResultGrid.SelectedItem == null) return;
            AmazonItem item = ResultGrid.SelectedItem as AmazonItem;
            if (item.URL == null)
            {
                MessageBox.Show("The item's URL cannot be parsed.");
                return;
            }
            OpenWebpage(item.URL.ToString());
        }