Does anyone have an idea how I can disable Drag and Drop for all my TextBox elements? I found something here , but I will need to run a loop for all the elements.
You can easily wrap the description of this article in an attached property / behavior ...
T. TextBoxManager.AllowDrag = "False" (For more information, check out these two CodeProject articles - Drag and Drop Example and Example Glass Effect Link Text )
Blend SDK Behaviors
UPDATE
InitializeComponent()
DataObject.AddCopyingHandler(textboxName, (sender, e) => { if (e.IsDragDrop) e.CancelCommand(); });
ex MyTextBox: TextBox :
protected override void OnDragEnter(DragEventArgs e) { e.Handled = true; } protected override void OnDrop(DragEventArgs e) { e.Handled = true; } protected override void OnDragOver(DragEventArgs e) { e.Handled = true; }
TextBox, , :
/// <summary> /// Represents a <see cref="TextBox"/> control that does not allow drag on its contents. /// </summary> public class NoDragTextBox:TextBox { /// <summary> /// Initializes a new instance of the <see cref="NoDragTextBox"/> class. /// </summary> public NoDragTextBox() { DataObject.AddCopyingHandler(this, NoDragCopyingHandler); } private void NoDragCopyingHandler(object sender, DataObjectCopyingEventArgs e) { if (e.IsDragDrop) { e.CancelCommand(); } } }
TextBox : NoDragTextBox, "local" NoDragTextBox. / TextBox.
http://jigneshon.blogspot.be/2013/10/c-wpf-snippet-disabling-dragging-from.html
Source: https://habr.com/ru/post/1712668/More articles:Does BitArray list a lot of boxing / unboxing? - performance"order by" taking too long in mysql - mysqlDisallow calling public constructors except XML serializer - c #library for sending trackbacks / pingbacks in php - trackbackПроблема с Javascript - javascriptexchange attributes openid - attributesWhy is my task not working on CruiseControl (cannot find nunit)? - nunithttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1712671/a-class-diagram-is-to-a-program-as-a-is-to-a-database&usg=ALkJrhg_I7-avMPM__-2dPG7NAyQRFf1yQIs there a tool that can check for unnecessary reference exceptions? - c #Repainting the panel - c #All Articles