Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a borderless application by making the main window invisible, then I created a border and adjusted the corner radius to make my application look appealing.

I have made the minimize/maximize/close buttons although when the application is maximized the border stays the same height and width. I would like it so the height and width would change when maximized or have the ability to be dragged wider etc.

I know the main window can be made resizeable either "CanResize" or "CanResizeWithGrip" however these functions are not available solely to the border.

Does anyone know how I am able to solve this? i.e. Make the border resizable?!

Any help is appreciated. Thanks.

Here is my XAML:
HTML
Title="TITLE" Height="400" Width="600" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}" Icon="/TITLE;component/Images/TITLE1.png">
    <Grid>
        <Border BorderBrush="#50000000" BorderThickness="4" HorizontalAlignment="Left" Margin="12,12,0,0" Name="TITLEBorder" VerticalAlignment="Top" CornerRadius="100,40,100,40" MouseLeftButtonDown="TITLEBorder_MouseLeftButtonDown" MinWidth="554" MinHeight="337" MaxWidth="Infinity" MaxHeight="Infinity" >
            <Border.Effect>
                <DropShadowEffect x:Name="TITLEBorderShdw" BlurRadius="44" ShadowDepth="0" Color="Black"></DropShadowEffect>
            </Border.Effect>
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#8649E3BA" Offset="0" />
                    <GradientStop Color="#89FFFFFF" Offset="1" />
                    <GradientStop Color="#AF4CA2CC" Offset="0.639" />
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Button Name="CloseButton" Style="{StaticResource ResourceKey=CloseButton}" Height="20" Width="20" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20,4" Click="CloseButton_Click" />
                <Button Name="MinimizeButton" Height="20" Width="20" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="64,4" Style="{StaticResource ResourceKey=MinimizeButton}" Click="MinimizeButton_Click" />
                <Button Name="MaximizeButton" Style="{StaticResource ResourceKey=MaximizeButton}" Height="20" Width="20" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="42,4" 
Click="MaximizeButton_Click" />
                <Button Name="RestoreButton" Style="{StaticResource ResourceKey=RestoreButton}" Height="20" VerticalAlignment="Top" Margin="484,4,42,0" Click="RestoreButton_Click" />
            </Grid>
        </Border>
    </Grid>
</Window>


Okay, I have made these improvements; I would now like it to be resizable? either by grip or this paragraph which was found using google, although it was not explained "You wil need to trace mouseEvents on your widget, change the cursor if the mouse in a specific corner.
Then catch mouse press events and resize your widget on mouse move events. ", Help/Explaination?

HTML
Title="TITLE" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}" Icon="/TITLE;component/Images/TITLE1.png">
 <Grid>
     <Border BorderBrush="#50000000" BorderThickness="4" HorizontalAlignment="Right" Margin="12,12,0,0" Name="TITLEBorder" VerticalAlignment="Stretch" CornerRadius="100,40,100,40" MouseLeftButtonDown="TITLEBorder_MouseLeftButtonDown" Width="640" Height="360" >
Posted
Updated 18-Sep-11 12:32pm
v3
Comments
Mehdi Gholam 17-Sep-11 8:07am    
So you are saying the border stays the same size while your form is resized?
Hooolagon 17-Sep-11 8:19am    
Yes that is correct although I would like the border to be resizable as the form is not visible..
Simon Bang Terkildsen 18-Sep-11 0:20am    
There obviously must be something wrong in your XAML, use "Improve question" and post your XAML
Hooolagon 18-Sep-11 16:51pm    
Hello, the question now contains the XAML

1 solution

You've set VerticalAlignment and HorizontalAlignment to Top and Left so you're telling WPF that you want the Border in the upper left corner and to size the border based on the desired size of the Child of the Border.
So Remove VerticalAlignment and HorizontalAlignment or set them to Stretch.


Set ResizeMode to CanResize then you can resize your window. Now as I understand you want to resize the Border and not the window, for some reason. The only way to do that is to implement the functionality yourself.

0) You'll need something the user can crap onto to resize, like a Thumb or any Control would do. I suggest you use Thumb[^]
1) You must handle the appropriate events; MouseXX/DragXX depending on what you chose in 1)
2) You must update the width and height of the Border yourself in the appropriate event.
 
Share this answer
 
v2
Comments
Hooolagon 18-Sep-11 18:34pm    
Thanks, I made improvments now I think i require it to be resizable like every other window, i have given it a 16:9 ratio... Would like it to just be resizable by grip etc or have a limit to the maximum edges, etc
Hooolagon 18-Sep-11 18:34pm    
I have edited the question once again
Simon Bang Terkildsen 18-Sep-11 18:52pm    
Answer updated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900