Hi,
My application it's using the diagram and i needed to override the SelectAll() command since i have a special shape in the diagram i dont want to get deleted. This is the first shape added to the diagram. So diagram.Items[0].
I've created the newbinding as follows
var controlAllBinding = new CommandBinding(DiagramCommands.SelectAll, OnSelectAllExecute, OnCanSelect); CommandManager.RegisterClassCommandBinding(typeof(PatternDiagram), controlAllBinding);
And the implementation
private static void OnSelectAllExecute(object sender, ExecutedRoutedEventArgs e)
{
var diagram = (sender as PatternDiagram);
diagram.SelectAll();
(diagram.Items[0] as RadDiagramShape).IsSelected = false; //This works
(diagram.Items[1] as RadDiagramShape).IsSelected = false; //This works
}
private static void OnCanSelect(object sender, CanExecuteRoutedEventArgs e)
{
e.canExecute = true;
e.Handled = true;
}
However there are a few other items that are not RadDiagramShapes but they inherited from it (ProductShape : RadDiagramShape), there are 2 kinds of this products, the ones that are enabled and the ones that are disabled using the IsEnabled property.
So:
- 2 RadDiagramShapes (Rectangles) [CANNOT BE DELETED]
- 3 ProductShapes (IsEnabled = true) [SHOULD BE DELETED AND SELECTABLE]
- 3 ProductShapes (IsEnabled = false) [SHOULD NOT BE DELETED]
If i try to use a foreach inside the diagram.Items or diagram.SelectedItems and after that i try to check which ones are disabled and when i get them i try to use IsSelected = false (because i dont want them to be selected or deleted) it is not working.
I've tried to modify CanSelect, SelectAll, CanDelete, DeleteExecute, PreviewSelectionChange, SelectionChange with no luck.
Is there maybe about the ProductShape class that is not working? The class only has 2 properties and a predefined style.
Is there any way i can achieve this?
Thanks