From: Giulio Petrucci on
Hello there,

starting from this minimal XAML

<Window x:Class="Acme.Graph.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border BorderBrush="Black" BorderThickness="2"></Border>
<Rectangle Grid.Column="0" Height="40" Width="40"
Fill="Black"></Rectangle>
<Canvas AllowDrop="True"></Canvas>
</Grid>
</Window>

the main window has:
- on the left side: a black square
- on right side: a canvas
I need to implement this behaviour: dragging the black square onto the
canvas, when the black square is dropped, a imilar square is drawn on
the canvas.

How would you approach the problem in a WPF-style? Triggers? Commands?
Or a lot of code-behind, like in WinForms?

Thanks in advance.
Ciao,
Giulio

--
From: Andy O'Neill on

"Giulio Petrucci" <fakename(a)fakedomain.com> wrote in message
news:%23IrAeux2KHA.5880(a)TK2MSFTNGP02.phx.gbl...
<<>>
> the main window has:
> - on the left side: a black square
> - on right side: a canvas
> I need to implement this behaviour: dragging the black square onto the
> canvas, when the black square is dropped, a imilar square is drawn on the
> canvas.
>
> How would you approach the problem in a WPF-style? Triggers? Commands? Or
> a lot of code-behind, like in WinForms?

You need code.
You can't just drag and drop uielements from one parent to another without
any code.
One of your problems will be the way the visual tree works.
Once your black square has a parent it needs to be disconnected from it
before you can add it to another parent, like your canvas.

Google drag and drop smorgasbord

There is a web forum specifically aimed at wpf which you might want to ask
future questions in.
Over on social.msdn.microsoft.com/Forums
But I'll tell you the same thing over there.