c#


Drag an image from a treeview and drop on canvas example in WPF


Yes, I have repeatedly googled the subject and read numerous articles that are either too broad or too precise for what I need. Yes, I know this is Stackoverflow, so I'm ready for the snarky comments, downvoting and general abuse. And, yes, I actually wrote something in 2011 very similar to what I need but since then I had a year of chemo and my memory isn't what it used to be.
What I have is a treeview called OOB and a canvas called UnitLayerCanvas:
I want to click on a node in the treeview OOB, use the image associated with the node - I believe it's called an 'adorner' - drag it over to the canvas UnitLayerCanvas on the right and drop it. I need to know what node was clicked on in the treeview OOB and where it landed (X,Y) on the canvas UnitLayerCanvas. That's it.
Can somebody please direct me to an example in C# that explains this process? I have seen a lot of examples that involve treeview to treeview dragdrop and that's not what I need.
Update
I've got my old code working to the point where it can identify the node in the Treeview that was clicked on. I'm now wrestling with the adorner code.
Another Update
Got the adorner to work. Now just the drop. But, seriously, this is 20 times harder than it needed to be.
Using CNuts comments i will give you an idea
You must have an object that contains the item itself, and its position x and y
Then on your map you should have a collection of these items, then:
public class MapItem
{
public object Item {get;set;}
public int X {get;set;}
public int Y {get;set;}
}
List<MapItem> MapItems {get;set;}
So now you have to get mouse position using
MouseButtonEventArgs e (Mouse Events)
ex.:
Point _startPoint = e.GetPosition((StackPanel)sender);
then
MapItem mapitem = new MapItem { X = _startPoint.X, Y = _startPoint.Y, Item = YourItem }

Related Links

Show differences between two DataTables in C# with LINQ
Bluetooth baseadapter and listview in C#
Resource Based Authorization [duplicate]
How to find a Control by it's name in c# Windows [duplicate]
Multiple LEFT JOINS in dbf (dBase)
SslStream and PFX certificate failed
Additional information: InvalidArgument=Value of '0' is not valid for 'index'
Start menu will cover the Window when not open in Visual Studio
SQLDATASOURCE - Updating database using datavaluefield in combobox
Run a Infinite Running Background Task with Xamarin.Forms on Android
How to write object to a file opened by another process with async await pattern?
Bot Framework: Exit PromptDialog without giving an answer
Deserializing XML in C# where a property could be either an attribute or an element
How to keep image on Button to show on mouse-over? WPF
The data reader is incompatible with the specified, …does not have a corresponding column in the data reader with the same name
Simple Odata Client Inside Portable Class Library

Categories

HOME
c#
classification
nagios
conceptual
django-middleware
query-string
uml-designer
meson-build
samsung-gear-s2
segmentation-fault
activejdbc
mamp
suitecrm
fine-uploader
saucelabs
opendaylight
tag-cloud
brightway
amazon-data-pipeline
openam
cucumberjs
google-street-view
novacode-docx
conditional-formatting
keystone
gomobile
mattermost
opengraph
wai-aria
android-cursorloader
cloudformation
launchd
windows-10-mobile
git-submodules
units-of-measurement
lines
log4net-configuration
apache-falcon
tunnel
campaign-monitor
sdl-2
motherboard
jquery-inputmask
nscollectionview
ui-grid
rexx
intervention
amazon-fire-tv
logan-square
easyquery
bioperl
r-commander
opticalflow
cc
robotc
apache-commons-cli
timefield
easy-thumbnails
boost-range
networkstream
xcode7.1
altova
instaparse
git-cherry-pick
database-administration
datamodel
sqldataadapter
app-data
imageicon
sdkman
gulp-cdnizer
uinavigationitem
callfire
glog
log-analysis
opennebula
jeet-grid
ultraedit
accpac
chunks
jsonmodel
redmine-plugins
sendy
internet-radio
flask-mongoengine
autofilter
static-class
coinbase-php
nx
mmo
screensharing
inflate
esi
motordriver
expresso-store
mvcmailer
jqueryi-ui-buttonset
visual-leak-detector
code-organization
parallel-python
openwrap
backlight
opendir
marathontesting
nyromodal
mysql-logic
web-search
calendarextender
datadude
scala-designer
cstring

Resources

Encrypt Message