This is a migrated thread and some comments may be shown as answers.

Avoiding RadDiagramShape being deleted

2 Answers 40 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Deepak Shakya
Top achievements
Rank 1
Deepak Shakya asked on 09 Nov 2012, 07:47 AM
Hi,

The EditTemplate of the Shape has a textbox. When I deleted the data in the textbox and by chance the user presses the delete one more time, the shape get the focus and is deleted. This is nuisance when the Edit template contains more than one textboxes and the rest of the data has been filled.

How do we avoid the shape being deleted when editing the data? Is there a way so that the focus remains in the textbox even when there is no data?

The sample (DiagramsMvvmSample) can be downloaded from my skydrive

Cheers
Deepak

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 09 Nov 2012, 09:55 AM
Hi Deepak,

Thank you for bringing this issue to our attention. I investigated it and I can confirm that this is a bug, which I logged in our PITS. Also I updated you Telerik's points accordingly.

Until a fix is provided I can suggest you a workaround - you can handle the KeyDown event for the TextBox in the ShapeEditTemplate and check if the pressed key is Delete and if the TextBox's text is empty. If both conditions are fulfilled you have to handle the event. Here is a snippet ot the code I used for this approach:

private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key.Equals(Key.Delete) && (sender as TextBox).Text == String.Empty)
    {
        e.Handled = true;
    }
}

Please give this workaround a try and let us know if it works for you.

All the best,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Deepak Shakya
Top achievements
Rank 1
answered on 09 Nov 2012, 01:09 PM
Hi Stefan,

Thanks for providing the workaround and logging the issue in PITS. I will use the solution until the issue has been resolved.

Cheers!
Tags
Diagram
Asked by
Deepak Shakya
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Deepak Shakya
Top achievements
Rank 1
Share this question
or