예제 #1
0
        private void ClearModel(FrameworkElement elt, object item)
        {
            ModelUIElement3D model = elt.GetValue(LinkedModelProperty) as ModelUIElement3D;

            _modelContainer.Children.Remove(model);

            // Update the positions of all model items
            int removed = (int)model.GetValue(LinkedElementPositionProperty);

            foreach (Visual3D m in _modelContainer.Children)
            {
                int val = (int)m.GetValue(LinkedElementPositionProperty);
                if (val > removed)
                {
                    m.SetValue(LinkedElementPositionProperty, val - 1);
                }
            }

            model.ClearValue(LinkedElementProperty);
            elt.ClearValue(LinkedModelProperty);

            // Update SelectedIndex if needed
            if (SelectedIndex >= 0 && SelectedIndex < Items.Count)
            {
                ReflowItems();
            }
            else
            {
                SelectedIndex = Math.Max(0, Math.Min(SelectedIndex, Items.Count - 1));
            }
        }
        private void ClearModel(FrameworkElement elt, object item)
        {
            ModelUIElement3D model = elt.GetValue(LinkedModelProperty) as ModelUIElement3D;

            _modelContainer.Children.Remove(model);

            model.ClearValue(LinkedElementProperty);
            elt.ClearValue(LinkedModelProperty);

            // Update SelectedIndex if needed
            if (SelectedIndex >= 0 && SelectedIndex < Items.Count)
            {
                ReflowItems();
            }
            else
            {
                SelectedIndex = Math.Max(0, Math.Min(SelectedIndex, Items.Count - 1));
            }
        }