Ejemplo n.º 1
0
        private void CreateItemPopup(UIElement target, Item item)
        {
            var popup = new Popup
            {
                AllowsTransparency = true,
                PopupAnimation     = PopupAnimation.Fade,
                StaysOpen          = true,
                PlacementTarget    = target
            };

            // Use a grid as child to be able to disconnect the hover control properly.
            var grid = new Grid();

            popup.Child = grid;

            target.MouseEnter += (o, e) =>
            {
                ItemHover.DataContext = ItemHoverViewModelFactory.Create(item);
                grid.Children.Add(ItemHover);

                popup.IsOpen = true;
            };
            target.MouseLeave += (o, e) =>
            {
                popup.IsOpen = false;
                grid.Children.Clear();
            };
        }
Ejemplo n.º 2
0
        private Image getMouseOverImage(Image img, Item item)
        {
            var itemhover = new ItemHover()
            {
                DataContext = ItemHoverViewModelFactory.Create(item)
            };

            Popup popup = new Popup();

            popup.PopupAnimation  = PopupAnimation.None;
            popup.StaysOpen       = true;
            popup.Child           = itemhover;
            popup.PlacementTarget = img;
            img.MouseEnter       += (o, e) => { popup.IsOpen = true; };
            img.MouseLeave       += (o, e) => { popup.IsOpen = false; img = null; GC.Collect(); };
            return(img);
        }
Ejemplo n.º 3
0
        public Image getImage()
        {
            Image img = new Image();

            if (!imageCache.ContainsKey(Item.IconURL))
            {
                using (var stream = ApplicationState.Model.GetImage(Item))
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = stream;
                    bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    bitmap.Freeze();
                    imageCache.Add(Item.IconURL, bitmap);
                }
            }

            img.Source = imageCache[Item.IconURL];
            var itemhover = new ItemHover()
            {
                DataContext = ItemHoverViewModelFactory.Create(Item)
            };

            Popup popup = new Popup();

            popup.AllowsTransparency = true;
            popup.PopupAnimation     = PopupAnimation.None;
            popup.StaysOpen          = true;
            popup.Child           = itemhover;
            popup.PlacementTarget = img;
            img.Stretch           = Stretch.None;
            img.MouseEnter       += (o, e) => { popup.IsOpen = true; };
            img.MouseLeave       += (o, e) => { btns_MouseLeave(popup, e); img = null; GC.Collect(); };
            return(img);
        }