Advertisement

Silverlight FloatableWindow update: start position and resizable

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. 


This work is licensed under a Creative Commons Attribution By license.

  1. 7/8/2009 11:59 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hey Tim,

    About that resizing grip, why not display it when the mouse is over the window (maybe together with the "close" button top right, and show them very faded when the mouse is not over the window?

    Cheers,
    Laurent
  2. 7/8/2009 12:04 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Laurent -- actually that was my original design. Here was my thinking...

    In Winforms, the resizing grips, etc. are a part of the window chrome usually, so they aren't taking up any usable space (usually they are a part of some reserved toolbar/statusbar space). In WPF/Silverlight I thought in this instance you'd want to have the usable space reserved for whatever you are doing in the Window. having something always there that took up space seemed "not XAML" to me :-).

    I'm open to suggestions though, maybe I'll try it out again.
  3. 7/8/2009 1:02 PM | # re: Silverlight FloatableWindow update: start position and resizable
    I agree with Laurent. It will be very obvious to user of what they are supposed to do. If a feature is "hidden", it won't be used as many people won't know its there.
  4. 7/8/2009 1:28 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Laurent/yaip: two votes is good enough for me :-) -- I reverted back to the original design where the semi transparent handle is always visible.
  5. 7/8/2009 8:01 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Sweet GIF animation :)
  6. 7/9/2009 1:36 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Tim this is great, and would be just what we need for an application we're working on at present. One thing though - do you know if the Z-order problem will be fixed before release of SL3? It's a showstopper if not, and we'd have to revert to simply using a collection of user controls on a canvas to represent our "windows" - we've written a quick demo of this setting the z order on these does seem to work.
  7. 7/9/2009 8:36 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Greg -- ZIndex will not be fixed in SL3 for Popup. Can you help me understand your scenario for multiple float windows like this? I need customer evidence to support the fix. Feel free to send to me privately (with a screenshot would be nice) at timheuer@microsoft.com.
  8. 7/9/2009 12:00 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Wow this is great. We planned to update SilverlightDesktop.net to Silverlight 3 in the next few weeks so now we know what to do with the Windows :)
  9. 7/10/2009 3:14 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Tim, have emailed a quick explanation and demo.
  10. 7/10/2009 4:57 AM | # re: Silverlight FloatableWindow update: start position and resizable
    hello how r u
  11. 7/10/2009 5:20 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Tim,
    I'm a big fan of your blog. This floatable window rocks! I have a question that I can't seem to figure out. When I look at the class

    public class FloatableWindow : ContentControl
    {
    ...
    }

    I don't see any XAML markup??? FloatableWindow inherits from ContentControl ... how does it know how to render the UI elements ... like the resizer, "x", and the section at the top of the window). This part is a little advanced and I am not understanding how I can go in and modify the window's xaml.

    Thanks for a very insightful blog, Tim.

    Best regards,

    Chris
  12. 7/11/2009 1:31 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hey Tim, Hopefully this may help others who had the problem I did. I was trying to get the last window clicked to show in front of any of the other windows. There is a method in your code, "BringToFront()" that fires when you click on a window so it should work, but for me it didn't.

    The reason was I was creating the window with code like:

    FloatableWindow1 fw = new FloatableWindow1();
    fw.Title = "Testing FloatableWindow";
    fw.ResizeMode = ResizeMode.CanResize;
    fw.HorizontalOffset = 200;
    fw.VerticalOffset = 200;
    fw.Height = 400;
    fw.Width = 600;
    fw.Show();

    This wont work. I had to use code like:

    FloatableWindow1 fw = new FloatableWindow1();
    fw.Title = "Testing FloatableWindow";
    fw.ResizeMode = ResizeMode.CanResize;
    fw.HorizontalOffset = 200;
    fw.VerticalOffset = 200;
    fw.Height = 400;
    fw.Width = 600;
    this.LayoutRoot.Children.Add(fw);

    Now it works fine :)

    Basically replace "fw.Show()" with "this.LayoutRoot.Children.Add(fw)"
  13. 7/11/2009 2:53 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Michael -- yes, as I note there is a bug with Popup and ZIndex which makes my BringToFront() function essentially useless. Note your method (and as others have pointed out in the original post as well) changes this, but also changes the underlying behavior of the Window -- i.e., try using the close button in the title chrome :-)
  14. 7/11/2009 11:35 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Here's a question for you Michael (and others who hopefully will read this): Does matching the open/close animation of ChildWindow today matter for this concept I've been calling FloatableWindow? We could eliminate hosting the window in a Popup (and the ZIndex problem goes away), but would have to manage adding/removing it from the visual tree when open/closed.
  15. 7/12/2009 11:49 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Tim,

    I think that the "User Story" you were working on is about Popups. Well, Myself and 1000+ of my "closest friends" on SilverlightDesktop.net are interested in creating Silverlight Applications that act and behave like normal Windows applications.

    This is why we care about things like z-index. If someone really wants a Popup don't they always want that popup to be on the top? So to me there is no Z-index bug with Popups, the Popup should always be on top :)

    Anyway, I have been plugging away at the great code example you provided because unlike the current Windows for SilverlightDesktop.net, your control is coded "correctly" with all the proper Templating ect.

    We are very excited with the new possibilities to eventually allow people to upload a "skin" for SilverlightDesktop.net site much in the same way you can upload a skin for a DotNetNuke site.

    I have posted a blog and sample code of where we are so far at:
    silverlightdesktop.net/Default.aspx
  16. 7/13/2009 3:20 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Thanks a bunch for this. Helping me out a lot!

    Is there a way to close the current popup (or ALL popups) from the outside? My problem is when using a webpage mixed with silverlight content, as opposed to silverlight only page, The user navigates something on the webpage which does a ajax post and tells the silverlight control to load some new data. If they have a popup open, they STILL need to manually close it even though the ajax post should have invalidated the current view (in the silverlight control) and refreshed it.
  17. Gravatar
    7/16/2009 11:58 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hey, Tim. Thank you for this blog, helps me a lot.

    Been trying to add rotation capabilities to your FloatableWindow with the following code:

    TransformGroup g = this.ContentRoot.RenderTransform as TransformGroup;
    RotateTransform t = new RotateTransform();
    t.Angle = this._rotation; // new field I defined
    g.Children.Add(t);

    No matter where I put it, I always get a null reference error...

    BTW I'm using Michael's approach to embed the window because I don't need it to be a popup.
  18. 7/16/2009 3:52 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Just what I was looking for. Thanks!

    Can you recommend a book/website that explains how to actually write this kind of controls? Something like Nikhil's "Developing Microsoft ASP.NET Server Controls and Components," for Silverlight?
  19. 7/21/2009 8:57 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Dan -- try putting empty transform nodes in the XAML before hand (generic.xaml) and see if that works.
  20. 7/21/2009 9:56 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hey Tim, Thanks for responding on the Microsoft forums (this is puckoff from there) the demo looks solid and is definitely a critical piece of the puzzle that was missing from Silverlight!

    Keep up the good work!
  21. 7/22/2009 6:29 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Tim,

    Thanks again for this code! No, I was not creating it in XAML... but in C# code (I thought that was what your example above was showing us)

    After I read your post I tried to add a FloatableWindow in my MainPage.xaml but I couldn't get it to show up in the autocomplete... did I miss something in the installation or integration of your template with Visual Studios?

    One other question, after reading your previous posts... regarding the Z-ordering... you said this is on the Microsoft roadmap?

    One of my co-workers found this simple Silverlight 2.0 example...

    shinshu.fm/MHz/88.44/archives/0000268891.html

    definitely not nearly as nice as yours BUT he hacked around the z-ordering with a neat trick... basically the problem we are having is the z-ordering is static based on creation time right? So what he does is, when you click on an older window, he deletes it and recreates it... that basically brings it to the front.

    I am going to investigate this further and if possible, I would like to try and add this to your FloatableWindows.

    Take a look at the source code ( dotnet.sakura.ne.jp/.../...tMdiApplication_src.zip ) and tell me what you think, if you need any help with the Japanese, you can email me at puckoff7337 AT google mail
  22. 7/22/2009 7:28 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Cain -- make sure you add a reference to the FloatableWindow.dll after you compile it. Unfortunately the new item templates don't do that automatically (I'd love to figure out how to do that!).

    Z-ordering. The issue is only with Popup and ZIndex in Silverlight. There is an open bug, but I'm not sure of the priority. For now that's why I've changed the non-modal behavior to be that of not using Popup so the ZIndex works.
  23. 7/24/2009 7:36 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,
    I try your control and it is very good.
    I want to give you one suggestion.. If possible then add Minimize, Maximize functionality to your control.

    I see similar functionality in Adobe Flex.
    Like examples.adobe.com/.../main.html

    Thanks,
    Viral
  24. 7/31/2009 11:19 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Why not use Thumb controls to resize and move the window?
  25. 7/31/2009 11:50 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Yarlen -- because that would be logical ;-) -- sometimes I forget what controls are out there...that's a great suggestion! Added floatablewindow.codeplex.com/.../View.aspx
  26. 8/12/2009 6:54 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hello again.
    Why you do not use something like
    this.Width += e.HorizontalChange;
    this.Height += e.VerticalChange;
    in _resizer (thumb) dragdelta event to resize and
    something like
    this.transform.Y += e.VerticalChange;
    this.transform.X += e.HorizontalChange;
    in a drag (thumb control, dragdelta event) to move the window
  27. 8/12/2009 7:03 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim, it´s me again.
    I have made a Silverlight FloatableWindow from scratch inspirated in your code, I am adding three buttons (maximize, minimize and close)in the template, but i can not acces the click event for the buttons, Can you help me with any suggestion?
  28. 8/12/2009 11:05 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Yarlen -- I'd love to see the changes and we can put them in the project.
  29. 8/12/2009 5:40 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim.

    I have a doubt.

    When i add a floatablewindow, i cant set beggin point always start in the center and continues to the right. Why is this?
    Can you help me with any suggestion?

    I have tried with

    fw.HorizontalOffset = 5;
    fw.VerticalOffset = 5;

    but it doesnt function

    Sorry for my english
  30. 8/17/2009 4:19 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Erick,

    The reason it's doing that is probably because you're not passing it a Canvas for your ParentLayoutRoot (you're probably passing in a Grid) and you're trying to show a non-modal window. If you look around line 1369 in the latest source of FloatableWindow.cs you'll see that the offsets for non-modal windows will only work for Canvas layouts. Not sure if this a bug or not but one easy workaround is to create a Border then Canvas in the layout root. Basically my XAML looks something like this:

    <UserControl>
    <Grid x:Name="LayoutGrid">
    <Border>
    <Canvas x:Name="LayoutCanvas">
    </Border>
    </Grid>
    </UserControl>
  31. Gravatar
    8/18/2009 6:18 AM | # re: Silverlight FloatableWindow update: start position and resizable
    I've started messing with the FloatableWindow and noticed there seems to be some padding added within the window that I can't get to go away. Very simply create a FloatableWindow, set its Background to red (for example) and run the app - there is whitespace between the edge of the window and the background color.

    I tried setting padding="0" but that had no effect. In fact, setting Padding= to anything seemed to have no effect on its content presentation.

    Is there a setting that I'm missing or is this a limitation in the control?
  32. 8/18/2009 7:38 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Imu - I wouldn't call it a limitation, but that's the design of the control. There is probably part of the border/grid getting in your way. You can style the control template any way you want or change the default properties in generic.xaml.
  33. 8/19/2009 11:12 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,

    I really like this control, but I've got a few problems using it. Maybe you can help me out with it.

    When using it like:

    FloatableWindow1 fw = new FloatableWindow1();
    fw.Title = "Edit hours";
    fw.ResizeMode = ResizeMode.CanResize;
    fw.Height = 600;
    fw.Width = 1000;
    canvasHours.Children.Add(fw);

    It will be displayed on screen without a problem, but the close button will not work.

    When using it with the fw.showdialog(),

    It will popup fine, I can close it, but now a nullreferenceexception will appear in line this.ParentLayoutRoot.Children.Remove(this).

    Am I doing something wrong or forgetting something?
    Thanks....
  34. 8/20/2009 1:35 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Egbert. Instead of adding it to your canvas do this:
    fw.ParentLayoutRoot = this.canvasHours;
    fw.Show();
  35. 8/26/2009 12:46 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hello Tim,
    great control, i'am new in silverlight and blend, maybe you can help me.
    In your downloadable source code (FloatableWindow_1.3.zip) you have an "FloatableWindowTemplate.vsi" to install this control in VS to add simply a new Item FloatableWindow.
    How could i add it in blend, is there a "My template" selection too?
    Best regards

    André
  36. 8/26/2009 7:33 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Andre - Expression Blend doesn't have the code snippet support like VS does. In Blend you'd want to add a reference to the FloatableWindow.dll and then it will show up in the Controls pallette when you search for it.
  37. 8/26/2009 8:09 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,
    I add fw1.ResizeMode = ResizeMode.CanMinimize when Creating the Form, Dose it means the Form can Minmize? but it dose not work and How Can I make the Form Minimize?
  38. 8/26/2009 8:13 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Allen - Minimize/Maximize are not supported in this control right now.
  39. 8/26/2009 9:12 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Thanks Tim,

    So I create Minimize and Maximize button on the form title, but i can not control the point of form when click the button.
    when Minimize click i use
    Canvas.SetTop (this, (double)0);
    Canvas.SetLeft (this, (double)0);
    (I want set the form to the left, up position when click the Minimize button)
    when Maximize click i use
    this.SetValue(Top, (double)250);
    this.SetValue(Left, (double)200);

    if the form do not be dragged to a new position, when click the Minimize button ,the form will be correct position,but if the form have been dragged to a new position, the code dose not work well!SO how can i solve this question?
    and Minimize/Maximize Function will be ok in the next version?

  40. 8/27/2009 4:45 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,
    I want to create a floatablewindow in anohter form'Canvas
    and i use ChildForm.ParentLayoutRoot = FatherForm.MainCanvas , but the Form is unvisual! but if i use ShowDialog , it will be ok!
  41. 8/27/2009 7:32 AM | # re: Silverlight FloatableWindow update: start position and resizable
    I have solved it
  42. 9/10/2009 10:35 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim
    I am create the float able window when it is shown can i able to work the background of the window and i want the minimize button for this window how can i archive this
  43. 9/11/2009 8:22 AM | # re: Silverlight FloatableWindow update: start position and resizable
    trinath - minimize isn't built in to the control right now.
  44. 9/23/2009 2:22 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,
    This is great, and really needed in the toolkit.
    I have a problem (I think). My modal window is displayed in the middle of my screen, normally outside the Silverlight usercontrol.
    I am using the 3.0.40624.4 Release, and a subclassed FloatableWindow in this way

    My Page.xaml:
    --------------
    <UserControl x:Class="Jplan.Page" Width="Auto" Height="Auto"
    ...
    xmlns:floatWin="clr-namespace:System.Windows.Controls;assembly=FloatableWindow">
    <Canvas x:Name="LayoutRootCanvas" Background="Gray">
    <Border Width="740" Height="640"
    BorderBrush="#FF084C64" BorderThickness="3,3,3,3" >
    <Grid x:Name="LayoutRootGrid" Background="#FF75CEEE">
    .... (more xaml code)
    </Grid>
    </Border>
    <Popup x:Name="contextMenu" ... >
    <Grid Opacity="0.8">
    ...
    </Grid>
    </Popup>
    </Canvas>
    </UserControl>


    My Code-behind:
    ...............
    public partial class Page : UserControl
    ...
    MyDialog md = new MyDialog(LayoutRootCanvas);
    md.HorizontalOffset = 100;
    md.VerticalOffset = 100;
    md.ShowDialog();
    ...

    public class MyDialog : FloatableWindow
    {

    public MyDialog(Canvas layoutRoot)
    {
    this.ParentLayoutRoot = layoutRoot;
    Canvas m_canvas = new Canvas();
    m_canvas.Height= 190;
    m_canvas.Width= 275;
    Border border = new Border();
    border.BorderBrush = new SolidColorBrush(Colors.Blue);
    border.BorderThickness = new Thickness(2);
    border.CornerRadius = new CornerRadius(3);
    border.Child =m_canvas;
    TextBlock txtblock = new TextBlock();
    txtblock.Text = "Hello world";
    Canvas.SetLeft(txtblock, 10); Canvas.SetTop(txtblock, 10);
    this.Content = border;
    }
    }
  45. 9/23/2009 9:55 AM | # re: Silverlight FloatableWindow update: start position and resizable
    The Modal (ShowDialog) will always show in center. Show() is what I added and listens to the offsets -- interesting point though -- if you think it should always listen to the offsets can you log a work item on the project?
  46. Gravatar
    9/23/2009 9:20 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,

    I want to ask you that:
    I have a Page.xaml which contains a button name: btnSayHi
    when I click btnSayHi, It would show the MyDialog (which made from ChildWindow)
    That MyDialog contains two buttons: btnYes, btnNo

    In Page.xaml.cs the btnSayHi's event is:
    private void btnSayHi_Click(object sender,...)
    {
    MyDialog myDialog = new MyDialog();

    if (myDialog.Show("Do you like it") == Result.Yes)
    {
    btnSayHi.Text = "You clicked Yes";
    }
    else
    {
    btnSayHi.Text = "You clicked No";
    }

    // when my dialog closed...this below line would be affected
    this.btnSayHi.IsEnabled = false;
    }

    How can I do that??? I don't like to create Closed event of MyDialog because I like to do manythings in btnSayHi click event :(

    Do you have any comments??? Thank you so much :)
  47. 10/10/2009 8:01 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,

    Great work as always. Would you be able to suggest a way for me to programmatically reposition a FloatableWindow on the Canvas (with the click of a button, set it on the top left corner)? I was also trying to figure out if it were possible to set hard boundaries at the edges of the Canvas to prevent part of a FloatableWindow from moving off the edge.

    Thanks!
  48. 10/28/2009 9:29 AM | # re: Silverlight FloatableWindow update: start position and resizable
    I had issues with the Popup Z-Index as well. I didn't want my popup content to be part of the visual tree because they are respectively their own window. And when I tried doing my windows in the visual tree, it raised an argument error, probably because of duplicate elements in the same tree.

    The solution I've found is to quickly toggle the IsOpen property for the element you want to bring to the front. Not a very elegant solution but I NEED this functionality. And it does work out so you don't see the hide/show rendering (in my code).
  49. 11/2/2009 8:12 AM | # re: Silverlight FloatableWindow update: start position and resizable
    See this code in FloatableWindow OnOpened:
    if (!this.Focus())
    {
    // If the Focus() fails it means there is no focusable element in the
    // FloatableWindow. In this case we set IsTabStop to true to have the keyboard functionality
    this.IsTabStop = true;
    this.Focus();
    }

    If the window has a control like a TextBox that can get focus, it does not get the focus because this.Focus() has diverted it. I commented out this section of code to get it to work. Any suggestions for a better solution?
  50. 11/2/2009 1:26 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Silverlight allows more controls on the screen than traditional HTML web apps. A DataGrid plus a DataForm will be a common combination. Rather than prescribing where and with what size these components are shown, I'd like to make them floatable (and resizable, and minimizable). This way THE SAME app could run on a smart phone and still all controls could be used together. So isn't what we actually want a generic Window control? Having, like a ScrollViewer or Border, a Window control that adorns other controls with a drag handle and minimize button, displaying a thumbnail in a collapsed state?

    (The FloatableWindow does not behave so well when it's defined in XAML - it displays with IsOpen == false.)
  51. 11/3/2009 1:58 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Great Job as you always do. I want to implement the same floating window template onto a dragdockpanel which is part of black light controls, shown in the show case link under (mightymeaty.members.winisp.net/blacklight.silve...) dragdockpanel we have dragdockpanelhost with 6 dragdockpanel and content inside them. I want each dragdockpanel to act as a floating window and with content inside them. Is this possibel ? So that he can maximise window using maximise button, minimise using the same button and can also resize the existing size and shrink the panel in that row or column.
    Any idea on how to implement this would be greatly appreciated.
    Thanks,
    Sumray
  52. 11/12/2009 4:12 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Thanks Tim - very, very useful.
  53. 11/23/2009 5:47 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim!
    I consider this a very useful control (I was really looking for it), but I still can't understand why there are differences of how it works on Canvas and Grid?
  54. 12/8/2009 4:40 PM | # re: Silverlight FloatableWindow update: start position and resizable
    This is a very useful control. Thanks. I'm using it as a Please Wait... dialog
    when something happens in the background. Thanks
  55. 1/11/2010 9:56 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,

    I am thinking to use this floatablewindow as a non-modal window. But the problem I am facing is it doesn't show my given title in the title bar instead shows incremental number if I click on this window. Also on resize it shows x-y coordinate.

    Is there any way to make Title static one like "My Pop" intead of showing x-y coordinate.

    Thanks
  56. 1/11/2010 1:05 PM | # re: Silverlight FloatableWindow update: start position and resizable
    hey,

    can anyone help me out on this?

    Thanks
  57. 1/11/2010 1:13 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Pndeys - there is a debug compile check in the code. If you compile in non-Debug mode, then you'll see your title.
  58. 1/11/2010 1:28 PM | # re: Silverlight FloatableWindow update: start position and resizable
    thanks Tim, it worked
  59. 1/15/2010 9:25 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi

    I define a flotable window in xaml
    <Canvas x:Name="LayoutRoot" >
    <rr:FloatableWindow x:Name="fw"></rr:FloatableWindow>
    </Canvas>

    In code I have
    fw.Title = "Thest";
    fw.ResizeMode = ResizeMode.CanResize;
    fw.Height = 150;
    fw.Width = 200;

    My problem is that the close button doesnt work
    In flotablewindow.cs the following line in the close method fails
    // Close Popup
    if (this.IsOpen)

    here IsOpen is false..
    Does anyone now how I can fix this?
  60. 1/20/2010 2:53 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,

    I love the FloatableWindow control, but I'm seeing some very odd behavior. When I call the Show() method, the dialog pops up similar to the ChildWindow controls (i.e. starts out very small and quickly expands to its full size.) However, sometimes you can briefly see the control at full size before it goes back to being small again and then expanding back to full size. This all happens in a fraction of a second, but it gives the appearance of the window being opened, closed, and then opened again. Is there any solution to this? I've tried setting the Visibility of the control but it doesn't seem to have any effect. I've moved my initialization code from the constructor to the Loaded event and that doesn't seem to matter. Any thoughts?
  61. 1/22/2010 2:32 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi Tim,
    This is a great control! Silverlight is now version 3, with a beta for 4 out - can't believe this is still a "sample" and not part of the core Silverlight functionality.
    I have discovered what may be a bug:
    In my application I create a FloatableWindow to show some content and store a reference to that window in a global variable so that it can be reopened in the same position with the same content. The problem is that if the window is already open when I call the Show() method, I get an error stating that "Element is already the child of another element". There doesn't appear to be any public properties I can check to see if it is already open.
    To solve this I needed to modify the source to do "this.ParentLayoutRoot.Children.Add(this);" only if _isOpen is false in the showWindow function. This seems to fix the problem, though I'm not sure if this broke something else as I'm rather new to all this.
  62. 1/25/2010 3:29 AM | # SetLeft and SetTop
    Hi
    Is there a bug with the SetTop and SetLeft properties of the FloatableWindow?
    If you make a global FloatableWindow and a Button
    In the button click event you set

    floatableWindow.SetValue(Canvas.LeftProperty, (double) 200);

    The first time you click it works. But if you then move the window and click again nothing happends. It seems like the LeftProperty is not updated when you move the window. Does anyone now how this can be fixed?
  63. 1/25/2010 6:28 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Also I would like to close a window using a button that calls
    floatableWindow.Close();

    This doent work either.. this.IsOpen is false in the Close() method.

    Does anyone have a clue as to how this can be fixed?
  64. Gravatar
    1/25/2010 7:14 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Hi,

    I have a FloatableWindow that I want to add a image to using code. Can you point toward an example of this?

    Thanx,

    DJ
  65. 1/26/2010 8:42 AM | # re: Silverlight FloatableWindow update: start position and resizable
    anyone?

    Is there a bug with the SetTop and SetLeft properties of the FloatableWindow?
    If you make a global FloatableWindow and a Button
    In the button click event you set

    floatableWindow.SetValue(Canvas.LeftProperty, (double) 200);

    The first time you click it works. But if you then move the window and click again nothing happends. It seems like the LeftProperty is not updated when you move the window. Does anyone now how this can be fixed?
  66. 1/29/2010 3:02 PM | # re: Silverlight FloatableWindow update: start position and resizable
    DJ just set
    floatableWindow.Content = yourImage
  67. 2/2/2010 2:17 PM | # What DLL include ?
    Hi !

    I want to use your FloatableWindow to have a "modal window" like Form.ShowAsModal in WindowsForm.
    I installed your package "FloatableWindow_1.3.zip", I added a new template "Silverlight Floatable Windows" to my project. But when i compile, Visual Studio say me that does not contain a definition for the type "FloatableWindow". So which DLL do I have to add to my project to use the "FloatableWindow"?

    Thank you for your reply,

    Nico
  68. 2/2/2010 2:56 PM | # Await the closing before continue
    Hi,

    I use your beautiful Floatable Window Control.

    How to make that the program awaits the closing of the window before continuing to run?

    Thank you.
  69. 2/2/2010 5:13 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Alexandre -- you can't. ChildWindow is an asynchronous control :-(
  70. 2/2/2010 5:15 PM | # re: Silverlight FloatableWindow update: start position and resizable
    Nico - there is a FloatableWindow.dll that you'd want to reference. If it isn't there, compile the source.
  71. 2/3/2010 3:41 AM | # 
    Ho.... OK

    And do you know a similar control which is synchronous?

    Thank you.
  72. 2/3/2010 8:06 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Alexandre -- I'm not sure if it is or not, but Telerik has a window control.
  73. 2/8/2010 5:06 AM | # re: Silverlight FloatableWindow update: start position and resizable
    Do you now why when adding a ScrollViewer to my usercontrol the BringToFront is not working on e.g. Textblock inside the ScrollViewer?
    If I remove this it works.
  74. 2/16/2010 8:03 AM | # re: Silverlight FloatableWindow update: start position and resizable
    i m trying to use the DLL from CodePlex.
    1) there seems to be some bug upon closing the window:
    Error: Unhandled Error in Silverlight Application
    Code: 4004
    Category: ManagedRuntimeError
    Message: System.NullReferenceException: Object reference not set to an instance of an object.
    at System.Windows.Controls.FloatableWindow.<Close>b__0(Object s, EventArgs args)
    at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

    2) why do i MUST add ParentLayoutRoot?? what should i do if i don't have it at hand? like when making a Prism service to handle it.
  75. 2/16/2010 9:00 AM | # re: Silverlight FloatableWindow update: start position and resizable
    regarding my #2: i see now what u've done in the ShowWindow method.
    if it is modal you play it like a ChildWindow.
    but why if it isn't modal you are adding it directly to the parent given in the ParentLayoutRoot?
    why not play the same game in both cases?

 
Please add 3 and 1 and type the answer here:
First time here? You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting! (hide this)