×

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!

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.


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
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.
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.
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.
7/8/2009 8:01 PM | # re: Silverlight FloatableWindow update: start position and resizable
Sweet GIF animation :)
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/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.
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 :)
7/10/2009 3:14 AM | # re: Silverlight FloatableWindow update: start position and resizable
Tim, have emailed a quick explanation and demo.
7/10/2009 4:57 AM | # re: Silverlight FloatableWindow update: start position and resizable
hello how r u
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
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)"
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 :-)
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.
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
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.
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.
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?
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.
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!
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
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.
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
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?
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
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
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?
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.
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
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>
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?
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.
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....
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();
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é
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.
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?
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.
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?

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!
8/27/2009 7:32 AM | # re: Silverlight FloatableWindow update: start position and resizable
I have solved it
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
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.
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;
}
}
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?
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 :)
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!
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).
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?
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.)
11/12/2009 4:12 PM | # re: Silverlight FloatableWindow update: start position and resizable
Thanks Tim - very, very useful.
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?
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
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
1/11/2010 1:05 PM | # re: Silverlight FloatableWindow update: start position and resizable
hey,

can anyone help me out on this?

Thanks
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.
1/11/2010 1:28 PM | # re: Silverlight FloatableWindow update: start position and resizable
thanks Tim, it worked
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?
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?
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.
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?
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?
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
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?
1/29/2010 3:02 PM | # re: Silverlight FloatableWindow update: start position and resizable
DJ just set
floatableWindow.Content = yourImage
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
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.
2/2/2010 5:13 PM | # re: Silverlight FloatableWindow update: start position and resizable
Alexandre -- you can't. ChildWindow is an asynchronous control :-(
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.
2/3/2010 3:41 AM | # 
Ho.... OK

And do you know a similar control which is synchronous?

Thank you.
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.
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.
Gravatar
4/14/2010 3:09 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi...

Thanks a lot for this control!

Any news on Minimize/Maximize functions cause I really need them?
4/14/2010 2:49 PM | # Minimize/Maximize
If you add those buttons yourself it should not be so difficult to add the functionality.
However I have noticed there is a 'bug' with the SetValue of the floatable window.
e.g.
floatableWindow.SetValue(Canvas.LeftProperty, (double) 100);
Doesnt work if you set it multiple times. I figured out that if you use a dispatchtimer and set it to 10 milliseconds and in the tick do the SetValue it works perfect.
So if you e.g. fire this when the minimize button is clicked you can modify the width height of the floatablewindow and it will work :)

I now this is not the desired solution but at least it works like a charm :)
5/20/2010 6:53 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,
Great Article! Would it be possible at all to draw the floating window out side of the browser's boundaries like a real floating mdi window?
Thanks!
5/20/2010 10:20 AM | # re: Silverlight FloatableWindow update: start position and resizable
Nese -- not yet.
5/20/2010 12:32 PM | # re: Silverlight FloatableWindow update: start position and resizable
Bummer! Thanks!
5/26/2010 8:18 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,


My application requires floatable and also dockable window just similar to toolbox in Visual studio. I think it would be great if you enhance it.

-Hema
6/22/2010 8:03 AM | # re: Silverlight FloatableWindow update: start position and resizable
Tim,

how do i get the x,y position or the margin(x,x,x,x) value after the window is moved from the initial location? because the VerticalOffset or HorizontalOffset always set to the initial location even after it is being moved.
I'd like to be able to save the last position of the opened windows to a database and when the user log back in the windows will be restored based on the last saved location.

Great control btw
Gravatar
6/24/2010 11:52 PM | # re: Silverlight FloatableWindow update: start position and resizable
I need to get the "size" of the FloatableWindow once it has been resized. For FloatableWindow's displayed using ShowDialog() the Height/Width values are for the entire area, and the _desiredContentHeight/Width values are private. The .Content.ActualHeight/Width are "off" by 20 pixels.

Basically after a user resizes the dialog I want to remember the adjusted size such that the next time the dialog is shown it remembers the user's preferred size.

Any suggestions?

Thanks!

Rob
6/25/2010 8:31 AM | # re: Silverlight FloatableWindow update: start position and resizable
If you do this you will be able to store the window state in isolated storage for the next time the user logs in

floatableWindow.SetValue(Canvas.LeftProperty, (double) 100);
Doesnt work if you set it multiple times. I figured out that if you use a dispatchtimer and set it to 10 milliseconds and in the tick do the SetValue it works perfect.
So if you e.g. fire this when the minimize button is clicked you can modify the width height of the floatablewindow and it will work :)
7/15/2010 11:33 PM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,

Any news on Minimize/Maximize functions?
Gravatar
7/16/2010 7:57 AM | # re: Silverlight FloatableWindow update: start position and resizable
I need to access property of the parent form. is this possible?
7/27/2010 11:32 PM | # Window opening
Hi, thanks for this control. I have a problem that was already described but there was no reply to it. When I call Show() for the FloatableWindow sometimes it appears smoothly but sometimes you can see a part of the window that appears and disappears very quickly before the dialog will be shown. How can I fix that?
8/5/2010 12:59 AM | # re: Silverlight FloatableWindow update: start position and resizable
Anyone now if it is possible to have resizing in on the border of the window and not just in the lower right corner? Would it take alot of changes to get this feature?
8/23/2010 11:42 PM | # re: Silverlight FloatableWindow update: start position and resizable
Tim, I'm having a hard time making the dynamically generated content of this window resizing properly. basically I'm trying to set the user control as content and when resizing the window content does not get re-sized, alignment changes and if you size float. window to the min., user control just disappears, once you start increasing the size of float. window, the user control pops back to it's original size and would not re-sized. Any tips on how to make contents of the Window re-size with it would be greatly appreciated!
8/25/2010 5:21 AM | # re: Silverlight FloatableWindow update: start position and resizable
when i add some content to the fwindow, and i update the content, the position resets. can somebody help:
FloatableWindow fwindow = new FloatableWindow();
fwindow.ParentLayoutRoot = myCanvas;
myCanvas.Children.Add(fwindow);
Canvas.SetLeft(fwindow, 80);
Canvas.SetTop(fwindow, 50);

Canvas fcontent = new Canvas();
fcontent.Children.Add(new TextBlock() { Text = "Hello World" });
fwindow.Content = fcontent;

After the user draggs the control, when I do the following, the position of the FloatableWindow resets. why:
Canvas c = (Canvas)fwindow.Content;
TextBlock t = c.Children[0];
t.Text = "Changed Text";
9/15/2010 6:47 PM | # re: Silverlight FloatableWindow update: start position and resizable
hi Tim,

I have no customized the window a lot - the close/resize only appear on mouse over and it is transparent (to be used as a container for panels of info on my timer). I have the live app but it keeps getting blocked as a spam comment.

I have 2 problems perhaps someone could shed some light on:

1) My windows don't close with animation (decrease scale down to 0) - I have to handle the Closing event manually. I use the windows on a Grid layout - would this affect functionality?

2) If you look at my app you can see that you can drag and resize the window outside of the viewable area (I am using a MainPage and Content area controls). How can I change it so that dragging/resizing is constrained by the parent window?

thanks a lot for the control!
Rodney
10/15/2010 3:27 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi . .
Im new to silverligt , but this app is exactly what i was lookin for but how can i make the x in the upper right corner close the window , it works for fw.showdialog() but not for this.LayoutRoot.Children.Add(fw);

Could you or someone show me a sample code for closing the window ?

thanks.
Gravatar
10/21/2010 2:29 PM | # re: Silverlight FloatableWindow update: start position and resizable
Rodney, have you found a way to solve your 2nd question? I'm in the same boat.
11/26/2010 3:31 PM | # re: Silverlight FloatableWindow update: start position and resizable
Has anyone implemented resizing by dragging on the sides and not just only the lower right corner? Is this hard to accomplish? If anyone could tell me how this can be done I would highly appreciate it!!
2/21/2011 5:53 AM | # re: Silverlight FloatableWindow update: start position and resizable
I am accepting the aforementioned issue. First of all I do not accept what absolutely is traveling on in Silverlight world. pass4sure mb2-633 There assume to be too abounding fizz words traveling about for technology and applications. pass4sure 70-502 I am a beheld flat user for ages. It appears to me that this is alone a baby alpha and MS is assured its countless of developers to embrace it. pass4sure 70-504 The atomic they could accept done is to bear something bigger structured. And a added complete technology
2/23/2011 2:15 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,

thanks for this great control I really hope it will make its way into the SL toollkit.

Right now I'm confronted with a situation where I would like to use a Grid as ParentLayoutRoot for displaying the FloatableWindow in non-modal mode. However the Grid control does not respect the Canvas.TopProperty and Canvas.LeftProperty which are both used for initial positioning. Therefore I'm wondering if someone out there already tried to come up with more a Grid friendly solution for initial positioning.
Gravatar
4/8/2011 2:54 AM | # re: Silverlight FloatableWindow update: start position and resizable
Are the latest sources at codeplex.com or in the zip posted above. I did not find a vsi file at codeplex.com or settings to generate the xml documentation file. (Perhaps I missed them.)
6/7/2011 4:36 PM | # FloatableWindow defined statically
I don't suppose there's a way to create a FloatingWindow as a standalone XAML+CS page is there? I created a ChildWindow, filled it with controls, and now want to swap out the inheritance to FloatableWindow - but can't seem to find the right namespace to derive from...


<controls:FloatableWindow x:Class="MYNS.Controls.FrmNotification"
xmlns="schemas.microsoft.com/.../presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Width="400" Height="300"
Title="Notification" FontSize="12">
...
</controls:FloatableWindow>

public partial class FrmNotification : FloatableWindow {
...
}

I can get a floatable up dynamically, but I want to define one statically.

Any idea?

6/9/2011 12:51 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,

its good to use your floatablewindow, but i just want to view my web cam in that floatable window. like in rectangle... we use a video brush to fill.... rectagle.fill.

in this floatable window how i put my video brush.



thanks in advance
kishor kumar M
6/26/2011 10:48 PM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,

Great solution, thanks. A one question: how to prevent moving of window (non-modal) outside canvas edges? Or make position fixed?

Thanks in advance!
4/16/2012 2:48 PM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim, I use this control heavily in my SL app and am looking at the implications of porting it to Metro/Win8 - will it work in metro?
4/26/2013 10:00 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi Tim,
I'm trying to use your floatable window in an MVVM pattern,
but having trouble because I can't (and shouldn't) get at the parent from the ViewModel.
Any suggestions?

Thanks,
5/2/2013 8:57 PM | # re: Silverlight FloatableWindow update: start position and resizable
@WilM - I haven't looked at this in a while. In general the ChildWindows were in a different visual tree which may be the problem.
11/14/2013 7:42 AM | # re: Silverlight FloatableWindow update: start position and resizable
For the BringToFront() issue, I used this approach. Gives a bit of a "bouncy" effect, but works

1. Get window from collection
2. Maximise();
3. foreach (MDIWindow w in collection)
if w is not window in question, then Minimize();

Hope this helps
2/22/2014 9:44 AM | # re: Silverlight FloatableWindow update: start position and resizable
Hi,
Is that possible to add floatablewindow to my page dynamically. for example, I have list of floatablewindow which referre to different activity which is in my database. the list of activity shown on treeview and by clicking each nodes it adds different floatablewindow to the page.

same what we have in ajax webpart by passing url we can add webpart to page.
2/23/2014 6:56 PM | # re: Silverlight FloatableWindow update: start position and resizable
@Yousef - it has been a long while since I've played with FloatableWindow, but I can't recall anything that would *block* it.

 
Please add 5 and 8 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.