MinHeight and MinWidth

May 20, 2010 at 3:30 PM

Hi!

The floatable window is great. I´m just wondering whether it supports MinHeight and MinWidth.
I used it like here:

<controls:FloatableWindow
           ...
           x:Class="MyFloatableWindow"
           Width="300" Height="200"
           Title="MyFloatableWindow"
           MinHeight="100"
           MinWidth="100">
...

But that does not work.

Any ideas?

Thanks!

 

 

Jul 30, 2010 at 10:49 AM

Ran into the same problem...

Any suggestions?

Nov 30, 2010 at 8:33 AM

You need to handle sizechagned event of control like below

private void FloatableWindow_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
{
   if (e.NewSize.Width < minWidth)
       this.Width = minWidth; 
   if (e.NewSize.Height < minHeight)
       this.Height = minHeight;
}

Feb 7, 2011 at 11:51 PM

This event only seems to fire the when the page is loaded.   Any other resize never calls this event.   Am I doing something wrong?

This event only fires the when the page is loaded.   Any other resize never calls this event.   Am I doing something wrong?

Here is my XAML:

 

<windows:FloatableWindow x:Name="ResultsContainer" Effect="{StaticResource dropShadow}" Background="{StaticResource CommonBackgroundBrush}"

MinWidth="400" MinHeight="220" Width="400" Height="220" ResizeMode="CanResize" Title="Test" Closing="ResultsContainer_Closing" SizeChanged

="ResultsContainer_SizeChanged">

 

Here is my code:

 private void ResultsContainer_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (e.NewSize.Width < ResultsContainer.MinWidth)
                this.Width = ResultsContainer.MinWidth;
            if (e.NewSize.Height < ResultsContainer.MinHeight)
                this.Height = ResultsContainer.MinHeight;

        }