Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF VS2010 size
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:
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?
 
   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 17-Sep-11 1:07am
Edited 18-Sep-11 13:32pm
v3
Comments
Mehdi Gholam at 17-Sep-11 8:07am
   
So you are saying the border stays the same size while your form is resized?
Hooolagon at 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 at 18-Sep-11 0:20am
   
There obviously must be something wrong in your XAML, use "Improve question" and post your XAML
Hooolagon at 18-Sep-11 16:51pm
   
Hello, the question now contains the XAML

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
Hooolagon at 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 at 18-Sep-11 18:34pm
   
I have edited the question once again
Simon Bang Terkildsen at 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)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Richard MacCutchan 145
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 18 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100