private void MenuItemOnClickToggleAttach(object sender, RoutedEventArgs e)
        {
            var menuItem     = sender as MenuItem;
            var contextMenu  = menuItem?.Parent as ContextMenu;
            var treeViewItem = contextMenu?.PlacementTarget as TreeViewItem;

            var services = TyeExplorerServices.Get <TyeServicesProvider>();

            switch (treeViewItem?.Tag)
            {
            case V1Service service:
                services.SetExcludedFromAttachToAll(service, !menuItem.IsChecked);
                break;

            case ReplicaContainer replica:
                services.SetExcludedFromAttachToAll(replica.Replica, !menuItem.IsChecked);
                break;
            }
        }
        private void TreeViewItemOnMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            e.Handled = true;

            var treeViewItem = sender as TreeViewItem;

            var tyeServicesProvider = TyeExplorerServices.Get <TyeServicesProvider>();

            var isAttachable = false;
            var isChecked    = false;

            switch (treeViewItem?.Tag)
            {
            case V1Service service:
                isChecked    = !tyeServicesProvider.IsAttachToAllAvailable(service);
                isAttachable = tyeServicesProvider.IsAttachable(service);
                break;

            case ReplicaContainer replica:
                isChecked    = !tyeServicesProvider.IsAttachToAllAvailable(replica.Replica);
                isAttachable = tyeServicesProvider.IsAttachable(replica.Service);
                break;
            }

            var contextMenu = FindResource <ContextMenu>(isAttachable ? "ContextMenuService" : "ContextMenuUnavailable");

            contextMenu.PlacementTarget = sender as TreeViewItem;
            contextMenu.IsOpen          = true;

            if (isAttachable)
            {
                var menuItemToggleAttach =
                    (MenuItem)contextMenu.Items[1];                      //TODO: why does this not work: contextMenu.FindName("MenuItemToggleAttach") as MenuItem;
                menuItemToggleAttach.IsChecked = isChecked;
            }
        }