Spontaneous Publicity
blogs are the new phone book

Hidden Gem in .net 3.5 SP1 Announcement

May 12, 2008 15:38 by Luke

There is some great stuff hidden in Time Sneath’s post announcing the WPF aspects of the .net 3.5 SPI release:

It's been a long time in coming, but we're finally adding the much-requested DataGrid control to WPF. This will ship out-of-band at first, just after we release 3.5 SP1…

...Another oft-requested control is the Office Ribbon, and I'm sure you'll be pleased to know that we're also shipping an implementation of that control, also out-of-band, before the end of the year. The ribbon will be fully implemented in WPF,

So there you have it, there is a DataGrid and a Ribbon control coming to WPF! This is really cool. Something else that is really great is it appears that the WPF team is starting to adopt the “out of band” release model that other developer tools such as Asp.net MVC are using. I think this is a huge step forward in terms of integrating customer feedback into their products.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: .Net | C# | WPF
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

A New Custom WPF Panel: SpanningStackPanel

March 13, 2007 09:15 by Luke

Nick Thuesen has just published a new custom WPF panel that functions like a stack panel but takes up the entire space provided to it. I love to see new custom panels come out. I think there should be a Codeplex project for custom WPF panels. Maybe if I write any clever ones of my own I will start one.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: WPF
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

My version of sombody else's code: Finding the Index of an item in a Drag Drop operation

March 6, 2007 16:57 by Luke

While working on an application that requires drag and drop, I ran into trouble when trying to figure out where in the target list (in my case, a ListBox) to insert the dropped item. I ran across Josh Smith's article Drag and Drop Items in a WPF ListView which covers (quite nicely) how to handle drag and drop operations within and between ListViews.  While reading through the code, I found that he uses some code from Dan Crevier which was posted on Lester's Blog. Ok, now that I have taken you through the tangled web of other people's code, I will share how I used the code and changed it a little to work in my situation.

 

public static Point GetMousePosition(Visual relativeTo) { Win32Point mouse = new Win32Point(); GetCursorPos(ref mouse); System.Windows.Interop.HwndSource presentationSource = (System.Windows.Interop.HwndSource)PresentationSource.FromVisual(relativeTo); ScreenToClient(presentationSource.Handle, ref mouse); GeneralTransform transform = relativeTo.TransformToAncestor(presentationSource.RootVisual); Point offset = transform.Transform(new Point(0, 0)); return new Point(mouse.X - offset.X, mouse.Y - offset.Y); } public static int GetIndexUnderDragCursor(ItemsControl control) { int index = -1; for (int i = 0; i < control.Items.Count; ++i) { if (control.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { DependencyObject item = control.ItemContainerGenerator.ContainerFromIndex(i); if (IsMouseOver(item as Visual)) { index = i; break; } } } return index; } public static bool IsMouseOver(Visual target) { if (target == null) return false; Rect bounds = VisualTreeHelper.GetDescendantBounds(target); Point mousePos = GetMousePosition(target); return bounds.Contains(mousePos); }

I didn't change the GetMousePosition method at all from what I found on Lester's blog.  Then I slightly modified some of Josh's code so that it is a little more general.  I hope this helps.  Suggestions welcome.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: C# | WPF
Actions: E-mail | Permalink | Comments (3) | Comment RSSRSS comment feed