|
i begin the WPF Drag and drop and this tutotrial is very simple and explicite (francais)
|
|
|
|
|
Hi,
Is there a customized version of the license file? The license link just points to the generic BSD licence with no copyright year or owner info.
Thanks,
DS
|
|
|
|
|
I have a Treeview populated with DiskSpec and DiskSet objects each in their own parent node. DiskSets contain DiskSpecs and thus I want to drag DiskSpecs down onto the DiskSet. I have implemented my DiskSet HierarchicalDataTemplate like so:
<HierarchicalDataTemplate DataType="{x:Type local:DiskSetViewModel}" ItemsSource="{Binding DiskSpecs}" >
<Grid Height="Auto" Width="Auto" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding}">
<TextBlock Text="{Binding MyDiskSet.DiskSetName}" d:LayoutOverrides="Width, Height" Style="{DynamicResource LargeText}" Grid.Column="1"/>
</Grid>
</HierarchicalDataTemplate>
When my Drop handler is executed, dropInfo.TargetItem is always null. Is there a better way to denote the drop target in XAML or am I way off?
Cory
|
|
|
|
|
Does what it says on the tin ... drag n drop working with custom handlers in mvvm scenario in about 5 mins from downloading it ,, NICE !
|
|
|
|
|
Hi to Steven and all other readers,
I must say this a very nice library. I like the fact that you can use it in MVVM scenario.
Too bad that for me I need to host that wpf control in a win form control.
I know of the problems that we are going to have if we try to drag something outside the wpf control in winform. The so called ms "airspace" problems with the adorner.
The only problem is that I thought it will work the adorner stuff at least inside the wpf control.
It doesn't seem to work. I get the not allowed mouse figure when I try to drag inside a listbox control(a listbox with a dragadorner template) hosted in the a winforms window.
I don't think is a problem if the drag adorner template because is just a string.
I looked through the code but I can't find where is the actual problem.
If you have any idea just give me a hint and I will make a fix and posted here also off course.
Regards,
Cristian-Mihai
|
|
|
|
|
I have a viewmodel with: AvailableScenes and Scenes as observable collections. I have each of them in a listbox, and I wanted the single viewmodel to be able to allow me to drag scenes from one listbox to the other. I get an exception in can accept data.
I had thought that it was an issue with the fact that I am binding to collectionviewsources so I can run filtering on both of those collections. However I shifted over to observable collections and still get the error.
That does make me wonder however if can accept data is going to fail if the source is a view on a collectionviewsource.
-- edit:
I have encapsulated each of those collections and filters into their own viewmodels now, and I am still crashing. I am losing the dropInfo.DragInfo object. It is going null on me when I drop and never reaching my IDropTarget implementations... I literally cannot distinguish anything about why my drag and drop is working in other cases and not this one.
--edit:
Ooops I was setting drag handler not drop handler on the markup...
|
|
|
|
|
what do you mean by setting the drop handler instead of drag handler...
can you make an example of this and explain.
thx Danny.
|
|
|
|
|
It has been long enough that I don't have the broken code but it was the difference between:
<br />
<Listbox.... dd:DragDrop.DropHandler={This}/> and <Listbox .... dd:DragDrop.Draghandler={this}/><br />
I just had put the wrong handler on there, and as such it wasn't able to work some of its internal code out. I haven't yet found a case for needing both handlers.
|
|
|
|
|
I am using attach command behavior, and I have list items of viewmodels that I open up for viewing on double click. I want to still let those double click events capture and fire. I am trying to see where in the code that gets lost when we make things drag and droppable. Any tips to point me in that direction would be hugely appreciated.
So basically my item template has an expander that is double clickable. The expander also includes a button in the header to open the viewmodel. So you can either double click or click the button. However, with the drag and drop turned on, the button does not work if the item is selected. The double click doesn't work because that always seems to select the item.
Thanks very much for posting this though. If I can get that double click back, it is exactly what I was looking for.
|
|
|
|
|
Ok so I found something that looks like it gets me there, but I am afraid I am missing something.
DragDrop.cs line 254 is e.Handled=true;
It has TODO: re-raise the suppressed event if the user didn't initiate a drag.
Ok so yeah, like the comments in the code say if I comment out that handled then you can't select multiple any more. I just don't know how to fulfil that todo.
modified on Tuesday, October 12, 2010 6:40 PM
|
|
|
|
|
Hi Danny,
No I'm afraid I haven't got an answer for that either. I've looked into various solutions and nothing seems to work. If you do find a solution, *please* let me know!
|
|
|
|
|
Hey,
I want to use this very nice drag & drop implementation as well, but I had the same problem with double click. For me, the solution I found here worked pretty good:
http://cf-bill.blogspot.com/2007/04/c-dragdrop-and-doubleclick.html[^]
I wrapped the whole content of the method DragSource_PreviewMouseLeftButtonDown in a simple
if (e.ClickCount == 1)
{
...
}
Cheers,
Marcel
|
|
|
|
|
hi could you do reordering animation like google chrome tabs when dragging?
|
|
|
|
|
|
any idea where should i start looking?
|
|
|
|
|
I want to change the example in http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop.aspx to satisfy the
senario that user can edit the pupil's FullName.
So,
1. In Window1.xaml,
(a)add following node
<Window.Resources>
<DataTemplate DataType="{x:Type local:PupilViewModel}" >
<DockPanel>
<TextBox Text="{Binding Path=FullName}" AcceptsReturn="True" MaxHeight="60" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" />
</DockPanel>
</DataTemplate>
</Window.Resources>
(b) Change
<ListBox Grid.Column="1" ItemsSource="{Binding Schools.CurrentItem.Pupils}" DisplayMemberPath="FullName"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"/>
to
<ListBox Grid.Column="1" ItemsSource="{Binding Schools.CurrentItem.Pupils}"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"/>
2. Run the program, exception thrown when drag and drop in Pupil's listbox, say error occur at the following
DefaultDropHander.cs and dropInfo.DragInfo is null.
protected static bool CanAcceptData(DropInfo dropInfo)
{
if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection)
{
return GetList(dropInfo.TargetCollection) != null;
}
else if (dropInfo.DragInfo.SourceCollection is ItemCollection)
{
return false;
}
else
{
if (TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data))
{
return !IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
}
else
{
return false;
}
}
}
3. Do I make something wrong or your library DO NOT support this senario ?
HJY
|
|
|
|
|
Hi,
I have a tree with a hierarchical datatemplate. I only want to allow certain type of nodes to be dragged.
While I'm able to set the IsDragSource for the entire TreeView, I'm not able to do it on specific node types.
This is a partial XAML of my TreeView:
<TreeView
x:Name="IdentityExplorerTree"
ItemsSource="{Binding Path=Domains}"
Width="Auto"
Height="Auto"
BorderBrush="{x:Null}"
Background="{x:Null}"
VerticalContentAlignment="Top"
HorizontalAlignment="Stretch"
Grid.Row="2"
Grid.RowSpan="2"
Margin="3"
>
<!--dd:DragDrop.IsDragSource="True"-->
<TreeView.Resources>
<HierarchicalDataTemplate
DataType="{x:Type identityExplorer:DomainTVIModel}"
ItemsSource="{Binding Path=Children}"
>
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="\Shared\Graphics\container.png" />
<TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}" />
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate
DataType="{x:Type identityExplorer:OUTVIModel}"
ItemsSource="{Binding Path=Children}"
>
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="\Shared\Graphics\container.png" />
<TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}" />
</StackPanel>
</HierarchicalDataTemplate>
For example I would like to set IsDragSource only on the first level of items (type DomainTVIModel).
When I tried to set it on the HierarchicalDataTemplate I get a runtime error:
System.Windows.Markup.XamlParseException was unhandled
Message=" Object of type 'System.Windows.HierarchicalDataTemplate' cannot be converted to type 'System.Windows.UIElement'. Error at object 'System.Windows.HierarchicalDataTemplate' in markup file 'whiteOPS;component/identityexplorer/resources/identityexplorercontrol.xaml' Line 99 Position 14."
Source="PresentationFramework"
LineNumber=99
LinePosition=14
NameContext="Resources"
StackTrace:
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.TemplateBamlRecordReader.TryReadTemplateElementRecord(BamlRecord bamlRecord)
at System.Windows.Markup.TemplateBamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TemplateTreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlTemplateSerializer.ConvertBamlToObject(BamlRecordReader reader, BamlRecord bamlRecord, ParserContext context)
at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.ReadElement(Int64 startPosition, XamlObjectIds contextXamlObjectIds, Object dictionaryKey)
at System.Windows.ResourceDictionary.CreateObject(Int32 valuePosition, Object key)
at System.Windows.ResourceDictionary.RealizeDeferContent(Object key, Object& value, Boolean& canCache)
at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
at System.Windows.FrameworkElement.FindBestMatchInResourceDictionary(ResourceDictionary table, ArrayList keys, Int32 exactMatch, Int32& bestMatch)
at System.Windows.FrameworkElement.FindTemplateResourceInTree(DependencyObject target, ArrayList keys, Int32 exactMatch, Int32& bestMatch)
at System.Windows.FrameworkElement.FindTemplateResourceInternal(DependencyObject target, Object item, Type templateType)
at System.Windows.Controls.HeaderedItemsControl.PrepareHierarchy(Object item, ItemsControl parentItemsControl)
at System.Windows.Controls.HeaderedItemsControl.PrepareHeaderedItemsControl(Object item, ItemsControl parentItemsControl)
at System.Windows.Controls.ItemsControl.PrepareContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.TreeView.PrepareContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
at System.Windows.Controls.Panel.reGenerateChildren()
at System.Windows.Controls.Panel.get_InternalChildren()
at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Microsoft.Windows.Themes.ClassicBorderDecorator.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at System.Windows.Controls.TabItem.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
at System.Windows.UIElement.OnPreviewGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e)
at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.UIElement.Focus()
at System.Windows.Controls.TabItem.SetFocus()
at System.Windows.Controls.TabItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WBX.whiteOPS.Client.DiagramDesigner.App.Main() in C:\wbxsvn\Branches\RSADemo-from-rev137\Client\WBXClient\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ArgumentException
Message="Object of type 'System.Windows.HierarchicalDataTemplate' cannot be converted to type 'System.Windows.UIElement'."
Source="mscorlib"
StackTrace:
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Windows.Markup.BamlRecordReader.ReadPropertyCustomRecord(BamlPropertyCustomRecord bamlPropertyRecord)
at System.Windows.Markup.TemplateBamlRecordReader.ReadPropertyCustomRecord(BamlPropertyCustomRecord bamlPropertyRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
InnerException:
Any ideas how I can accomplish this?
Thanks,
Guy
|
|
|
|
|
Hi Guy,
You can't apply IsDragSource to templates, only to controls.
What you need to do here is implement a drag handler - see part 2 of the article here:
http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop-ii.aspx
Let me know if you're still having problems.
|
|
|
|
|
That's what I ended up doing, I just thought there was a cleaner way to do it with XAML.
Thanks again,
Guy
|
|
|
|
|
First of all thanks for the article, got my 5
I'm trying to achieve the following:
1. Use the Visual of the dragged element as feedback to the user,
instead of the cursor.
2. Use a custom cursor for the drag.
I'm able to do this without your framework, based on a blog by
Jaime Rodriguez:
http://blogs.msdn.com/jaimer/archive/2007/07/12/drag-drop-in-wpf-explained-end-to-end.aspx
Do you have any ideas how to integrate this with the framework?
Thanks,
Guy
|
|
|
|
|
Article 2 in this series shows how to supply a drag template:
Drag and Drop in WPF - Part II[^]
Does that help you?
In addition, Jon Mitchell has created a branch in the project SVN where he's been working on providing a more Windows 7-style drag. IF the article above doesn't do everything you need, could you take a look at the "jon" branch and see if this helps you? I plan to merge his work into trunk at some point soon.
http://code.google.com/p/gong-wpf-dragdrop/[^]
|
|
|
|
|
I was hoping for some way to use an automatically generated visual of the dragged element, rather the supplying a predefined image.
I'll be keeping an eye on your project, keep up the good work
Guy
|
|
|
|
|
I just created a little helper class when you have multiple collections in a same viewModel:
public ConstructorMethod()
{
FunnyBearHelper = new DropHelper<FunnyBear>();
FunnyBearHelper.Dropped += FunnyBearHelper_Dropped;
}
void FunnyBearHelper_Dropped(object sender, DropHelper<FunnyBear>.EventArgsDrop<FunnyBear> e)
{
}
public class DropHelper<T> : IDropTarget
where T:class,new()
{
public event EventHandler<EventArgsDrop<T>> Dropped;
private void InvokeDropped(EventArgsDrop<T> e)
{
EventHandler<EventArgsDrop<T>> droppedHandler = Dropped;
if (droppedHandler != null) droppedHandler(this, e);
}
public void DragOver(DropInfo dropInfo)
{
if (!(dropInfo.Data is T)) return;
dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
dropInfo.Effects = DragDropEffects.Move;
}
public void Drop(DropInfo dropInfo)
{
InvokeDropped(new EventArgsDrop<T> { DropInfo = dropInfo, Obj = (T)dropInfo.Data });
}
public class EventArgsDrop<T>:EventArgs
where T : class, new()
{
public T Obj { get; set; }
public DropInfo DropInfo { get; set; }
}
}
|
|
|
|
|
Nice one!
After using it in several major applications, i can say this library is the most well implemented, easily extensible drag-drop solution i have seen for WPF
Author of Procreate, a 3D protein visualisation tool written in C#
|
|
|
|
|
|