Silverlight FloatableWindow update: start position and resizable| Comments
UPDATE: FloatableWindow is now on CodePlex for easier community contributions and management of latest source and builds. FloatableWindow CodePlex Project. If you like this idea VOTE FOR IT in the Silverlight Toolkit!
A while back I wrote a post where I refactored the Silverlight ChildWindow to create a non-modal window and I called it FloatableWindow (you can see why I’m not a good marketer…hey I could have called it Microsoft Silverlight ChildWindow Refactored Edition Express). A few folks found it useful, for which I’m appreciative of the comments.
My buddy Karl Shifflett decided to use it in Glimpse as the diagnostic window – thanks Karl! Karl even added some code to it to basically provide a start position (HorizontalOffset and VerticalOffset). Another request Karl had was to add resizing capabilities to the window.
I’m pleased to say that I added both of these features to the source. I modified Karl’s offset properties a bit to not only include them in the Show() override, but also as public properties that would be used if available. For resizing, I added a ResizeMode property which matches the System.Window.ResizeMode enumeration. I chose to use that enumeration for some consistency with WPF APIs, but frankly it really only supports CanResize and NoResize with the default being CanResize. You can see an example of the resizing capabilities here in this animation:
As you can see (sorry for the horrible animated image but just wanted to make it simple), the resizing handle will appear in the lower right corner of the window.
UPDATE: Based on Laurent/yaip’s feedback I reverted back to my original design, here’s the mouse out (normal) and mouse over states for the handle:
I chose to make it invisible unless someone moves their mouse into that position. Is that the wrong UX do you think? I know it isn’t entirely consistent with something like WinForms, but I wanted to be a little different.
Additionally I wanted to use the SizeNWSE Cursor as a normal WPF/WinForm window would use, but unfortunately that’s not a valid Cursor for Silverlight right now.
I did try to make the resizing adorner a template part so you could make it something else (right now it is just a path). I haven’t really tried messing with it that much though.
I think my math might be a bit off in some scenarios and I’m still frustrated with the Popup and ZIndex issue in Silverlight, but I know there is an open issue for Silverlight to look at this so I’m trying to stay calm about it. Anyhow, some subtle adds to make it hopefully just a bit more useful for anyone who cares (or cares to learn from it).
You can download the source code here: FloatableWindow_1.3.zip
Hope this helps and I appreciate any comments regarding the update or if you see issues in your scenarios.
Please enjoy some of these other recent posts...