/// <summary>
        /// This method is called when the selection changed event occurs. The sender should be the control
        /// on which this behaviour is attached - so we convert the sender into a <seealso cref="UIElement"/>
        /// and receive the Command through the <seealso cref="GetChangedCommand"/> getter listed above.
        ///
        /// The <paramref name="e"/> parameter contains the standard EventArgs data,
        /// which is unpacked and reales upon the bound command.
        ///
        /// This implementation supports binding of delegate commands and routed commands.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void Selection_Changed(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var uiElement = sender as TreeView;

            // Sanity check just in case this was somehow send by something else
            if (uiElement == null)
            {
                return;
            }

            ICommand changedCommand = TreeViewSelectionChangedBehavior.GetChangedCommand(uiElement);

            // There may not be a command bound to this after all
            if (changedCommand == null)
            {
                return;
            }



            ////if ((e.NewValue == null && e.NewValue == null))
            ////  return;
            ////else
            ////{
            ////  // Actual value did not really change
            ////  if ((e.NewValue != null && e.NewValue != null))
            ////  {
            ////    if ((e.NewValue == e.NewValue))
            ////    return;
            ////  }
            ////}

            // Check whether this attached behaviour is bound to a RoutedCommand
            if (changedCommand is RoutedCommand)
            {
                // Execute the routed command
                (changedCommand as RoutedCommand).Execute(e.NewValue, uiElement);
            }
            else
            {
                // Execute the Command as bound delegate
                changedCommand.Execute(e.NewValue);
            }
        }
        /// <summary>
        /// This method is called when the selection changed event occurs. The sender should be the control
        /// on which this behaviour is attached - so we convert the sender into a <seealso cref="UIElement"/>
        /// and receive the Command through the <seealso cref="GetChangedCommand"/> getter listed above.
        ///
        /// The <paramref name="e"/> parameter contains the standard EventArgs data,
        /// which is unpacked and reales upon the bound command.
        ///
        /// This implementation supports binding of delegate commands and routed commands.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void Selection_Changed(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var uiElement = sender as TreeView;

            try
            {
                // Sanity check just in case this was somehow send by something else
                if (uiElement == null)
                {
                    return;
                }

                bool isProcessing = TreeViewSelectionChangedBehavior.GetIsProcessing(uiElement);

                if (isProcessing == true)
                {
                    return;
                }

                ICommand changedCommand = TreeViewSelectionChangedBehavior.GetChangedCommand(uiElement);

                // There may not be a command bound to this after all
                if (changedCommand == null)
                {
                    return;
                }

                // Check whether this attached behaviour is bound to a RoutedCommand
                if (changedCommand is RoutedCommand)
                {
                    // Execute the routed command
                    (changedCommand as RoutedCommand).Execute(e.NewValue, uiElement);
                }
                else
                {
                    // Execute the Command as bound delegate
                    changedCommand.Execute(e.NewValue);
                }
            }
            catch
            {
            }
        }