.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

drag and drop into transparent canvas on transparent window

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :WPF



Short version: how can I drag/drop into a transparent window.


Long version:

I have a transparent borderless window with a transparent canvas in it. The canvas can hold usercontrols that can be dragged around (like gadgets, widgets).

I want the user to be able to click anywhere outside the gadgets but within the canvas and hit whatever that is behind, like other windows from other programs or icons on the desktop for example. This is easy because everything is transparent except the gadgets. The problem comes when I want to drag new gadgets in from another window. When the window and canvas is transparent, it is not allowed to drop anything on them... (the drop target canvas is not registering any mouse events)

So what I want is some kind of partial HitTestVisibility. For MouseDown in the canvas, it should be HitTestVisible=false, but when I drag something (my own stuff, not  files for example) over the canvas, it should be able to drop it.

I have tried setting the opacity of the background to 0.01 when entering the window with the mouse, that works sometimes if I have a small border that the mouseenter event can trigger on, but if I move the mouse to fast, it wont work.... So a 100% fool proof way of enabling Drop on a transparent control would be nice :)



View Complete Post

More Related Resource Links

Transparent WPF window blinks when background is redrawn

Hello everyone. I have a problem with a window which is transparent. If the background changes under the window, you can see that the whole window is redrawn, so it blinks and it doesnt look well.   <Window x:Class="Transparent" WindowStyle="None" AllowsTransparency="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Transparent" Background="Transparent" Width="190" Height="200" Topmost="True">   <Canvas Background="#FF444444" Height="200" Width="190" Name="TranspaerntCanvas"></Canvas> </Window> On some changing background it works fine (for example when I put it over a youtube video), but over openGL background the window is blinking. I use .NET 3.5 on win XP. Does anyone know, how to fix this problem? Thank you

WPF transparent window has white box arround it on XP but not vista

Hi I have a WPF Transparent window which works fine on Vista but on XP, there is a white box around it. I am not sure what's causing it on XP, any suggestions will be very much appreciated. R

How to implement Design-Time drag & drop from Custom Visual Studio Tool Window to WPF Designer

Hi, Could someone tell me if it is possible to intercept a design time drop event coming from a custom Visual Studio tool window onto the cider design surface? I am hoping to use the same API's as those used by the Visual Studio 2010 'Data Sources' tool window, which provides drag & drop data-binding between classes and WPF/Silverlight controls. My requirement is to pass a DataObject (used with the WPF DragDrop API) from my custom Visual Studio WPF tool window treeview to my custom WPF control at design time, read the data and do some binding/XAML manipulation of my own. The drag aspect is simple enough but I can't work out how to accept a drop event from anything other than the toolbox. At the moment, when I drag my treenode over the design surface it shows the 'cannot drop here' cursor. If someone could give me some insight into how the 'Data Sources' tool window allows dragging of treenodes to controls I would really appreciate it. It is obviously possible but which API's are used and are they public? Thanks in advance, Paul  

Drag and drop the dockable window to the desktop



I am using MDI Container in which am using Dockable Container. In Dockable Container, I have used multiple windows which are docked.

Now, when user drag the dockable window then it will be undock and allow user to drop it to the desktop. Also this window is shown in the taskbar.

Can anybody tell me, what should I do for it?

Behind Visible Window (No Transparent Window) ?



My there was a question about WPF.http://social.msdn.microsoft.com/Forums/en/wpf/thread/7190959b-b1c6-4cd3-8108-600becc8b03b

Same question but now subject is Windows Forms.I can making transparent windows (back of form is visible) with below code

this.BackColor = Color.White;
this.TransparencyKey = this.BackColor;

And I have a panel on form object.This panel's background color is transparent.Because panel's behind must be visible...and While Application running ,I'm clicking panel object.Rather I can't click to panel object.When I changed panel's background color to other color (except Color.Transparent) ,I can click panel object.What necessary I need to do ?

C Sharp Coder

Upload transparent PNG image


Hi everybody

I'm creating a website where it must  be able to upload, crop and resize images. This works until I use transparent PNG images. When I upload a transparent PNG, the transparency becomes black. I've searched the whole internet, but found no solution so far. Can someone help me? This is my code. I'm working with MVC 2.

			try {
				HttpPostedFileBase file = Request.Files["image"];
				file.SaveAs(Server.MapPath("/Uploads/" + file.FileName));

				ViewData["ImageLocation"] = "/Uploads/" + file.FileName;
				return View();
			catch (Exception exc) {
				return RedirectToAction("UploadImage");

Wicked Code: Drag and Drop with ASP.NET AJAX


Jeff Prosise shows how you can implement drag-and-drop functionality in your Web app with ASP.NET AJAX.

Jeff Prosise

MSDN Magazine January 2008

ASP.NET: Web Forms Let You Drag And Drop Your Way To Powerful Web Apps


Web Forms have the potential to change Web programming by introducing a new programming model built around server-side controls-a model in which controls render their own UIs by generating HTML to return to clients and firing events that are handled by server-side scripts. Since all the action takes place on the Web server, virtually any browser can run a Web Forms app. And thanks to Visual Studio .NET, building a Web Forms app is a lot like using Visual Basic: just drop a control onto a form then write an event handler. This article describes the Web Forms programming model, how it fits with ASP.NET, and introduces DataGrid, TextBox, and other classes in the .NET Framework class library.

Jeff Prosise

MSDN Magazine May 2001

Scott Howlett and Jeff Dunmall: Drag and Drop Data Manipulation Powered by XML


Building on the browser-based org chart featuring VML (Vector Markup Language) described previously in Microsoft Internet Developer, this article takes you through the process of refining that sample app by using XML, XSL, and JScript code to create a new, improved version. Drag and drop editing is added to the org chart interface thanks to built-in support found in Internet Explorer 5.0. XML and JScript allow data manipulated on the screen to be saved back to the server in its native format. The final product of this combination of XML, XSL, and VML is a high performance, scalable Internet app that uses processing on the client to reduce stress for the server.

Scott Howlett and Jeff Dunmall

MSDN Magazine March 2000

Asp.Net Treeview Drag n Drop


Hello all

How to make asp.net treeview drag and drop enabled on web. I am unable to find any javascript and there is not any event to make treeview drag and drop enabled.

Kindly suggest me how to use drag and drop facility in treeview.

I don't want to use any third party utility.

waiting for reply..........


Thanks in advance

Listview - Drag and Drop?


Hey everyone, I have a treeview and a listview on my ASP.NET application. However, with treeview I can drag and drop it to where ever I want it on my page. I tried this with listview, but it wouldn't let me. Listview automatically positions itself along the left side of my application. What I'm wanting to do is put my treeview along the right side and then put my treeview along the left side of the application. Any ideas on why I can't do this or suggestions on how I might be able to do this?

By the way, I'm running Visual Studio 2010 and using .NET FRAMEWORK 4.

Converting PNG to Transparent PNG


Hi there,

I have a bunch of PNG images and i want the background for each one to be transparent. At the moment they all have white background and i want to remove that. Can this be done programatically possibly with the help of some imaging component.

Thanks in advance.


Drag and Drop data binding and Enums

I'm using Visual Studio 2010 to design a simple WPF application. I created a simple class, with some Enum property, and added the class as a new data source, then dragged and dropped it from the Data sources window as a DataGrid. The result is a data grid that works properly, except for enum handling. Obviously, I want enums to be displayed as combo boxes, so I set the option. The problem is: I get a combo box column, but it is NOT populated with the Enum's values, instead only the current value is displayed and the user can't change it. This behavior seems completely useless to me. Am I doing something wrong here, or is there another explanation for this? Why isn't the designer handling enums in a sensible way? Another problem is, if I choose to drag the class as "Details". Again everything works except enums. I get a standalone combobox, but it displays the values of the property from the entire list, and choosing a different item in the combobox changes the active bound property. Once again, useless behavior - I expect the designer to create a combobox populated with values from the Enum, and for it to act like every other control in a master-details relationship - choosing a different value changes the state of the current item. Please advise.

Displaying transparent text using TextOut

Hi, I'm currently working on a C# project that displays transparent windows (like splashscreens) using Windows Forms. I've been using a class that allows me to call GDI Win32 functions such as UpdateLayeredWindow(), GetDC(), TextOut()... I can show a transparent PNG, it's ok but when I want to add a transparent text with TextOut it works but doesn't follow the form. In the TextOut function, I've tried to specify the HDC of the current form using e.Graphics.GetHdc() without success... Is there a way I can draw my transparent text so it follows the transparent form ? Here is my code, written within the Form_Paint method (private void Form1_Paint(object sender, PaintEventArgs e)). The HDC for the TextOut method used here is null so it draw within the screen DC. IntPtr Hdc = API.GetDC(IntPtr.Zero); IntPtr memDc = API.CreateCompatibleDC(Hdc); IntPtr hBitmap = IntPtr.Zero; IntPtr oldBitmap = IntPtr.Zero; try { //Display-image Bitmap bmp = new Bitmap(backgroundImage); hBitmap = bmp.GetHbitmap(Color.FromArgb(0)); //Set the fact that background is transparent oldBitmap = API.SelectObject(memDc, hBitmap); //Display-rectangle Size size = bmp.Size; Point pointSource = new Point(0, 0); Point topPos = new Point(this.Left, this.Top); e.Graphics.GetHdc() //Set up blending options API.BLENDFUNCTION blend = new API.BLENDFUNCTION(); blend.BlendOp = API.AC_SRC_O

Transparent child forms

Hi, I'm developing a Windows Forms application that uses an MDI and child forms. The MDI has an image for the background. I am trying to make the child form background be transparent so the MDI image shows through. I have trawled the internet, and from my understanding this is not possible. However, it seems to be possible in unmanaged code using API’s. Are there any examples of how to do this and what API I should use?   Many thanks in advance.   Andy (MCTS)

How can i make a WPF transparent group box control that is in the toolbox?

How can i make a WPF transparent Groupbox control that will show a picturebox image behind it? Thanks -civilwarrock
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend