How to add image inside the canvas using SilverLight
Hello everyone, can anyone help me out here? I am having some problem in SilverLight, as I am making one canvas with some images within it but I am not quite actually able to do that. Actually in drag and drop application, It must be able to place images inside the canvas, it is working that manner, but when I am trying to place some images outside the canvas it should be directly gone in to canvas, I think there must be mistake in coding, can any help me out with this? Every help will be appreciated. Please help me guys it is my college project and very stuck in these things. Thanks a lot in advance.
Re: How to add image inside the canvas using SilverLight
Hey I have seen your post, but I am able to get your exact doubt what you are trying to ask. But as per your some sentences I can understand that, and I have one solution for you. Just do some work on margin properties of an image, I mean set a negative left margin to your any desired image, and then put it too upper side, so that it will appear outside canvas when it is the part of canvas itself. I think you might trying to add images to canvas thru image control or adding it to background of canvas, you can also do that by using ImageControl event. Just try it and see is your problem is getting solved or not. All the best for your project.
Re: How to add image inside the canvas using SilverLight
Hey I have gone through your post, I think I know what you want and I have some coding for your coding part of canvas which will help you to fix your problem. Following code may help you:
<Grid x:Name="LayoutRoot" Background="White" AllowDrop="True" Drop="photopanel_Drop" DragEnter="photopanel_DragEnter">
This code calls the same events for grid for canvas, using this it will add the image of canvas only, and I think your problem will get solved
Re: How to add image inside the canvas using SilverLight
Hey don’t worry, when I was studying in college I have also suffered from this kind of situation. So be cool and I am giving you some event handler try those I think it will be very useful for you in future also. Following are the event handler:
- DragEnter,
- DragLeave
- DragDropTarget
- PanelDragDropTarget,
- ListBoxDragDropTarget
This event handler will sort out your problem regarding canvas, you just have to wrap PHOTOPANEL canvas with a PanelDragDropTarget and add Drop, DragEnter event to PanelDragDropTarget it will help you to change border color of canvas. All the best!!!