Пример #1
0
        private void ListviewItemDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lstInventory.SelectedItem == null)
            {
                return;
            }
            int currentIndex = lstInventory.SelectedIndex;
            Warehouse_Inventory inventory = lstInventory.SelectedItem as Warehouse_Inventory;
            InventoryInfoWindow window    = new InventoryInfoWindow(inventory);

            window.Owner = this;
            bool?result = window.ShowDialog().Value;

            if (result.HasValue && result == true)
            {
                Decorator    border       = VisualTreeHelper.GetChild(lstInventory, 0) as Decorator;
                ScrollViewer scrollViewer = null;
                double       theOffset    = 0;
                if (border != null)
                {
                    scrollViewer = border.Child as ScrollViewer;
                    if (scrollViewer != null)
                    {
                        theOffset = scrollViewer.VerticalOffset;
                    }
                }

                Window_Loaded(null, null);

                scrollViewer.ScrollToVerticalOffset(theOffset);
            }
        }
Пример #2
0
        private void miAdd_Click(object sender, RoutedEventArgs e)
        {
            InventoryInfoWindow window = new InventoryInfoWindow();

            window.Owner = this;
            bool?result = window.ShowDialog();

            if (result.HasValue && result == true)
            {
                Window_Loaded(null, null);
                lstInventory.ScrollIntoView(lstInventory.Items[lstInventory.Items.Count - 1]);
            }
        }