Laurent Kempé
Top achievements
Rank 2
Laurent Kempé
asked on 07 Jan 2013, 01:14 PM
Hi
I would like to avoid deselecting currently selected shape while clicking on the diagram.
When you click on the diagram, out of a shape, the currently selected shape is deselected.
I couldn't find a way to configure or do that.
Thanks for your help.
Cheers
Laurent Kempé
I would like to avoid deselecting currently selected shape while clicking on the diagram.
When you click on the diagram, out of a shape, the currently selected shape is deselected.
I couldn't find a way to configure or do that.
Thanks for your help.
Cheers
Laurent Kempé
6 Answers, 1 is accepted
0
Accepted
Hi Laurent,
Let us know if the suggested approach is suitable for you.
All the best,
Petar Mladenov
the Telerik team
The code below uses the MouseLeftButtonDown event of the RadDiagram, checks whether the clicked element is the RadDiagram and if yes, prevents the selection:
public
partial
class
MainWindow : Window
{
private
bool
shouldPreventSelection =
false
;
public
MainWindow()
{
InitializeComponent();
}
private
void
diagram_PreviewSelectionChanged_1(
object
sender, SelectionChangedEventArgs e)
{
if
(
this
.shouldPreventSelection)
{
e.Handled =
true
;
this
.shouldPreventSelection =
false
;
}
}
private
void
diagram_MouseLeftButtonDown_1(
object
sender, MouseButtonEventArgs e)
{
var element =
this
.diagram.InputHitTest(e.GetPosition(
this
));
if
( element !=
null
&& element.GetType() ==
typeof
(DiagramSurface))
{
this
.shouldPreventSelection =
true
;
}
}
}
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Hello Laurent,
Petar Mladenov
the Telerik team
This is ok if we don't use Rectangle Selection. Have you considered using it? What is the expected behavior that you wish to achieve when using it ?
Greetings,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Laurent Kempé
Top achievements
Rank 2
answered on 07 Jan 2013, 03:44 PM
Hi Petar,
Thanks it works correctly after changing this line
var element = rootDiagram.InputHitTest(e.GetPosition(rootDiagram)); //replacing the this
I don't know why I didn't found the PreviewSelectionChange and seen only the SelectionChange event. Maybe I was reading too much the doc which mention only Selectionchanged on http://www.telerik.com/help/wpf/raddiagrams-events-diagram.html and should have searched more in the code.
Never the less know it works the way I want, so thank you!
Cheers
Laurent Kempé
Thanks it works correctly after changing this line
var element = rootDiagram.InputHitTest(e.GetPosition(rootDiagram)); //replacing the this
I don't know why I didn't found the PreviewSelectionChange and seen only the SelectionChange event. Maybe I was reading too much the doc which mention only Selectionchanged on http://www.telerik.com/help/wpf/raddiagrams-events-diagram.html and should have searched more in the code.
Never the less know it works the way I want, so thank you!
Laurent Kempé
0
Laurent Kempé
Top achievements
Rank 2
answered on 07 Jan 2013, 03:46 PM
Hi Petar ,
Yeah I don't use it so it is fine!
Cheers
Laurent Kempé
Yeah I don't use it so it is fine!
Cheers
Laurent Kempé
0
Hi Laurent,
We're happy that the suggested solution works for you. Also, I'd like to thank you for notifying us about the documentation issue - we now added the PreviewSelectionChanged event description in the events article and the change will be reflected with the next upload of the online documentation.
I updated your Telerik points for this feedback.
All the best,
Tina Stancheva
the Telerik team
We're happy that the suggested solution works for you. Also, I'd like to thank you for notifying us about the documentation issue - we now added the PreviewSelectionChanged event description in the events article and the change will be reflected with the next upload of the online documentation.
I updated your Telerik points for this feedback.
All the best,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Laurent Kempé
Top achievements
Rank 2
answered on 07 Jan 2013, 04:54 PM
Hi Tina
Thanks
Thanks