Hi there, I've been working with Bea's solution here for a while and finding it very helpful. Problem now I'm having is when I drag-n-drop items within or to another ListView control and I want to scroll up/down "during" the drag (moving an item from index 30 to index 1), it's not happening. I would have to drag to the top of the visual items in the ListView, manually scroll up, then drag again, eventually ending at the position I want. This isn't very user friendly. Now I found the function (DragDropHelper.DropTarget_PreviewDragOver) that I would want to do the testing of which item is being dragged over, and I'm getting that. Dim pt As Point = e.GetPosition(DirectCast(Me.targetItemsControl, UIElement)) ' Perform the hit test against a given portion of the visual object tree. Dim result As HitTestResult = VisualTreeHelper.HitTest(Me.targetItemsControl, pt)
Now from there I can get the DependencyProperty of this visual hit Dim lvi As ListViewItem = TryCast(GetDependencyObjectFromVisualTree(TryCast(result.VisualHit, DependencyObject), GetType(ListViewItem)), ListViewItem)
Which is of a ListViewItem. Now in the function DropTarget_PreviewDragOver I have the "DraggedItem" which is of type Picture in Bea's example, but that can change depending on the ObservableCollection you have bound to the ListView. Now, I want to drag the ListView up or down depending on where the mouse is on the control. I've attempted with the below un-finished non-working code If lvi IsNot Nothing Then If pt.Y <= 25 Then Dim lv As ListView = TryCast(targetItemsControl, ListView) If lv IsNot Nothing Then Dim index As Integer = lv.Items.IndexOf(lvi) If index > 1 Then lv.ScrollIntoView(lv.Items(index - 1)) End If End If Else If pt.Y >= Me.targetItemsControl.ActualHeight - 25 Then Debug.Print("Scroll Down") End If End If End If
Can someone point me in the right direction to get this ItemsControl or ListView to scroll when dragging over the items?? Thanks!
snblackout
Posts
-
WPF ListView Databound Drag/Drop Auto Scroll -
WPF ListView/Items Control - Another problemThat worked great, thanks for all your help, I really appreciate it. I'm learning! :laugh:
-
WPF ListView/Items Control - Another problemThat did the trick. I have to ask though, why would I need to look for a different solution than the ListView for item counts greater than 100? What is the problem?
-
WPF ListView/Items Control - Another problemHi there, I posted yesterday a problem that I've fixed, but now I ran into another one. This is not a conversion problem, more like a bug. Please do the following in Bea's project to reproduce. 1. Open 'DataSource.cs' 2. Make the 'public Album()' look like below
public Album()
{
this.PicturesLeft = new ObservableCollection();
this.PicturesRight = new ObservableCollection();this.PicturesLeft.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\earglobe.gif", UriKind.Relative), "Earth", "Earth, our home planet, is the only planet in our solar system known to harbor life.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\jupglobe.gif", UriKind.Relative), "Jupiter", "With its numerous moons and several rings, the Jupiter system is a \\"mini-solar system.\\"")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\marglobe.gif", UriKind.Relative), "Mars", "The red planet Mars has inspired wild flights of imagination over the centuries.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\merglobe.gif", UriKind.Relative), "Mercury", "The small and rocky planet Mercury is the closest planet to the Sun.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\nepglobe.gif", UriKind.Relative), "Neptune", "Neptune was the first planet located through mathematical predictions.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\plutoch\_2.gif", UriKind.Relative), "Pluto", "Long considered to be the smallest, coldest, and most distant planet from the Sun.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\uraglobe.gif", UriKind.Relative), "Uranus", "Uranus gets its blue-green color from methane gas above the deeper cloud layers.")); this.PicturesLeft.Add(new Picture(new Uri("Images\\\\venglobe.gif", UriKind.Relative), "Venus", "At first glance, if Earth had a twin, it would be Venus.")); int i; for (i = 0; i <= 3; i++) { this.PicturesRight.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers.")); this.PicturesRight.Add(new Picture(new Uri("Images\\\\earglobe.gif", Uri
-
WPF ListView/ItemsControl Drag Drop AdornerGot it, with the help of Reflector. The online converter took this code
pen = new Pen { Brush = Brushes.Gray, Thickness = 2 };
and spit out
pen = New Pen()
conveniently leaving out the
pen.Brush = Brushes.Gray
pen.Thickness = 2and a couple other conversions that I had to fix that were similar. The converter could of done:
pen = New Pen() With {.Brush=Brushes.Gray, Thickness=2 }
but to play it safe because VS08 only supports that it just left it out.. Problem fixed!
-
WPF ListView/ItemsControl Drag Drop AdornerThanks for your reply, I'll give Reflector a go to see if I can see something, but with my experience the code that comes out of reflector can be somewhat cryptic at best. I did supply my attempt at converting the code in my original message, not sure if you downloaded and looked at it, the code I have compiles and runs fine in VB.net, just missing the InsertionAdorner working. Anyone willing to take a look at my already attempt at converting? Thanks, Scott
-
WPF ListView/ItemsControl Drag Drop AdornerHi there, I've found this article by Bea Stollnitz and downloaded the source and converted to vb.net. I believe I have my conversion complete, but one thing is still not working as I've tried to get it and pulled too many hairs out. Hopefully someone can help me spot what I'm missing. Ok, drag & drop works fine in the converted code, I just don't get the InsertionAdorner working in vb.net, I've setup breakpoints in code and all code is being executed, but for the life of me the InsertionAdorner does not become visible. Even the DrawLine functions are being called! I'm at a loss and I need this in vb.net, the original C# project works just fine, I just can't find out what I'm missing! Thanks, Scott
-
MySQL not liking certain "alias_name"Will do, but using the apostrophe near the enter key worked fine.. not sure if it'll raise problems down the road? I can use the other instead I guess.
-
MySQL not liking certain "alias_name"Surrounding the alias_name with the apostrophe worked dandy, thanks a lot for the tip, I've been thinking of how to use a different name, but "LayoutFile" is the best and I couldn't use it until you posted. Cheers! :-D
-
MySQL not liking certain "alias_name"Ah, that makes sense, thanks for clarifying.
-
MySQL not liking certain "alias_name"Yesterday I was in MySQL Query Browser building a SELECT statement. When I used the alias of "LayoutFile" in my SELECT statement, MySQL returns no resultset. Try it yourself. "SELECT (column) AS LayoutFile FROM (table)" - Replace (column) with of course, the column name, and (table) with, the table name. Now, change "LayoutFile" to whatever else you want (Ex. "LayoutFil", etc.) and it'll return the expected resultset. Ok, just did some testing and "LaoutFile" doesn't work either, strange stuff indeed. I haven't submitted this "Bug" to MySQL as of yet, I'm not sure how serious it is. I figure "LayoutFile" is a reserved word or variable inside MySQL? Anyone else think of something? :-D