public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return null;

            cache = cache ?? new Dictionary<string, Grid>();

            Item item = value as Item;
            string key = getKey(item);
            if (cache.ContainsKey(key))
                return cache[key];

            int inventoryId = int.Parse(item.InventoryId.Replace("Stash", "")) - 1;
            Grid g = new Grid();

            StashControl control = new StashControl() { TabNumber = inventoryId };
            Tab tab = ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs.Find(t => t.i == inventoryId);
            Image tabImage = getImage(tab, true);

            control.SetValue(StashControl.FilterProperty, new List<IFilter>() { new ItemFilter(item) });
            control.ForceUpdate();
            RowDefinition imageRow = new RowDefinition();
            imageRow.Height = new GridLength(26);
            g.RowDefinitions.Add(imageRow);
            g.RowDefinitions.Add(new RowDefinition());
            tabImage.SetValue(Grid.RowProperty, 0);
            control.SetValue(Grid.RowProperty, 1);
            g.Children.Add(tabImage);
            g.Children.Add(control);
            cache.Add(key, g);

            return g;
        }
        void stashView_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var filter = string.Empty;

            for (int i = 1; i <= ApplicationState.Stash[ApplicationState.CurrentLeague].NumberOfTabs; i++)
            {
                TabItem item = new TabItem();

                item.Header = StashHelper.GenerateTabImage(ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs[i - 1], false);
                item.Tag = ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs[i - 1].Name;
                item.HorizontalAlignment = HorizontalAlignment.Left;
                item.VerticalAlignment = VerticalAlignment.Top;
                item.Background = Brushes.Transparent;
                item.BorderBrush = Brushes.Transparent;
                StashControl itemStash = new StashControl();

                itemStash.SetValue(StashControl.FilterProperty, getUserFilter(filter));
                item.Content = itemStash;
                itemStash.TabNumber = ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs[i - 1].i;

                addContextMenu(item, itemStash);

                stashView.tabControl.Items.Add(item);
                tabsAndContent.Add(new TabContent(i - 1, item, itemStash));
            }

            stashView.Loaded -= new System.Windows.RoutedEventHandler(stashView_Loaded);
        }