C# WPF - Custom Control drag and drop (Visual Studio style)
up vote
0
down vote
favorite
How do I make my Custom controls draggable and droppable on a grid let's say?
I want to drag a panel(custom control) and drop it somewhere on my screen, in the best case in a grid, for example how it's done in Visual Studio, you can grab the solution explorer let's say and drop it somewhere, but how exactly do I do that?
c# wpf
New contributor
add a comment |
up vote
0
down vote
favorite
How do I make my Custom controls draggable and droppable on a grid let's say?
I want to drag a panel(custom control) and drop it somewhere on my screen, in the best case in a grid, for example how it's done in Visual Studio, you can grab the solution explorer let's say and drop it somewhere, but how exactly do I do that?
c# wpf
New contributor
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How do I make my Custom controls draggable and droppable on a grid let's say?
I want to drag a panel(custom control) and drop it somewhere on my screen, in the best case in a grid, for example how it's done in Visual Studio, you can grab the solution explorer let's say and drop it somewhere, but how exactly do I do that?
c# wpf
New contributor
How do I make my Custom controls draggable and droppable on a grid let's say?
I want to drag a panel(custom control) and drop it somewhere on my screen, in the best case in a grid, for example how it's done in Visual Studio, you can grab the solution explorer let's say and drop it somewhere, but how exactly do I do that?
c# wpf
c# wpf
New contributor
New contributor
New contributor
asked Nov 17 at 22:01
Krusto Stoianov
306
306
New contributor
New contributor
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42
add a comment |
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
what you are looking for is available on this thread
in coculsion:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//drag n drop setup
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
//hovering over form with file
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
//relising file into the form
void Form1_DragDrop(object sender, DragEventArgs e) {
string files = (string)e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
add a comment |
up vote
-1
down vote
You need to build your project and then it will be automatically available in the Toolbox when you are in the XAML designer. Just like the common controls.
For Drag and Drop at runtime look and the official WPF documentation. Also I suggest you look at the GongSolutions.WPF.DragDrop library in GitHub it is open source so you can see how they implemented it if the functionality it provides does not do what you want.
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
what you are looking for is available on this thread
in coculsion:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//drag n drop setup
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
//hovering over form with file
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
//relising file into the form
void Form1_DragDrop(object sender, DragEventArgs e) {
string files = (string)e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
add a comment |
up vote
0
down vote
what you are looking for is available on this thread
in coculsion:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//drag n drop setup
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
//hovering over form with file
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
//relising file into the form
void Form1_DragDrop(object sender, DragEventArgs e) {
string files = (string)e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
add a comment |
up vote
0
down vote
up vote
0
down vote
what you are looking for is available on this thread
in coculsion:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//drag n drop setup
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
//hovering over form with file
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
//relising file into the form
void Form1_DragDrop(object sender, DragEventArgs e) {
string files = (string)e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
what you are looking for is available on this thread
in coculsion:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//drag n drop setup
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
//hovering over form with file
void Form1_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
//relising file into the form
void Form1_DragDrop(object sender, DragEventArgs e) {
string files = (string)e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files) Console.WriteLine(file);
}
}
answered Nov 17 at 22:12
the Wongfon Semicolon
4317
4317
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
add a comment |
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
You didn't got me. I don't want to drag and drop files on my control. I want to be able to drag and drop that control, to be able to grab it and move it around the screen, and then drop it in another grid.
– Krusto Stoianov
Nov 18 at 10:39
add a comment |
up vote
-1
down vote
You need to build your project and then it will be automatically available in the Toolbox when you are in the XAML designer. Just like the common controls.
For Drag and Drop at runtime look and the official WPF documentation. Also I suggest you look at the GongSolutions.WPF.DragDrop library in GitHub it is open source so you can see how they implemented it if the functionality it provides does not do what you want.
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
add a comment |
up vote
-1
down vote
You need to build your project and then it will be automatically available in the Toolbox when you are in the XAML designer. Just like the common controls.
For Drag and Drop at runtime look and the official WPF documentation. Also I suggest you look at the GongSolutions.WPF.DragDrop library in GitHub it is open source so you can see how they implemented it if the functionality it provides does not do what you want.
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
add a comment |
up vote
-1
down vote
up vote
-1
down vote
You need to build your project and then it will be automatically available in the Toolbox when you are in the XAML designer. Just like the common controls.
For Drag and Drop at runtime look and the official WPF documentation. Also I suggest you look at the GongSolutions.WPF.DragDrop library in GitHub it is open source so you can see how they implemented it if the functionality it provides does not do what you want.
You need to build your project and then it will be automatically available in the Toolbox when you are in the XAML designer. Just like the common controls.
For Drag and Drop at runtime look and the official WPF documentation. Also I suggest you look at the GongSolutions.WPF.DragDrop library in GitHub it is open source so you can see how they implemented it if the functionality it provides does not do what you want.
edited Nov 18 at 20:25
answered Nov 17 at 22:11
AlesD
2,01827
2,01827
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
add a comment |
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I mean something else. I want to be able to grab the custom control from my window and move it, and in the best case be able to drop it in another grid
– Krusto Stoianov
Nov 18 at 10:39
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
I updated my answer to point you to some solutions.
– AlesD
Nov 18 at 20:26
add a comment |
Krusto Stoianov is a new contributor. Be nice, and check out our Code of Conduct.
Krusto Stoianov is a new contributor. Be nice, and check out our Code of Conduct.
Krusto Stoianov is a new contributor. Be nice, and check out our Code of Conduct.
Krusto Stoianov is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53355952%2fc-sharp-wpf-custom-control-drag-and-drop-visual-studio-style%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of C# WPF - Resizable Usercontrol / Page (Grab and drag resizing)
– ASh
Nov 18 at 7:18
No, it is not a duplicate. The one is for resizable panels, and this one is for garbbing panels and dropping them in a grid
– Krusto Stoianov
Nov 18 at 10:42