I'm using Silverlight 4 and Silverlight Toolkit April 10 release (dll is referenced from this folder: %Program Files%\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Bin). However, after registering t开发者_JS百科he namespaces, adding toolkit:DataGridDragDropTarget
to XAML results in this error:
`The tag 'DataGridDragDropTarget' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit'.`
Though, other DragDropTargets are available: ListBoxDragDropTarget, PanelDragDropTarget, TreeViewDragDropTarget.
I suspect it was some kind of omission mistake by the toolkit team when preparing the distribution package: if you download the toolkit source code (from here: http://silverlight.codeplex.com/releases/view/43528) and check the archive's Bin folder, System.Windows.Controls.Data.Toolkit.dll dll is there - that's the one that now contains the DataGridDragAndDrop itself. Just copy it to the rest of your tollkit distribution dlls and reference from your project:
<dataToolkit:DataGridDragDropTarget
x:Name="DragAndDrop"
xmlns:dataToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Toolkit"
AllowDrop="True" >
I don't know why it is gone from the toolkit, since there are lots of online samples that still use DataGridDragDropTarget
. I got around this problem by wrapping the grid inside PanelDragDropTarget
from the toolkit. Works like a charm.
<toolkit:PanelDragDropTarget x:Name="DragAndDrop" AllowDrop="True" AllowedSourceEffects="Move" >
<Grid x:Name="LayoutRoot" Width="400" Height="400" />
</toolkit:PanelDragDropTarget>
It is actually still in the binaries of the toolkit (at least those distributed via nuget), however it is in a different assembly to the other dragdrop helpers.
You will just need to add the following namespace definition:
xmlns:dragdrop="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Toolkit"
精彩评论