Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 C# XAML WPF
Is there any way to disable the maximize button in WPF page or to disable the resize property of page using XAML or C#
 

When I searched in Google , I got to disable it in WPF window
 
How can it possible in WPF page.
 
Pls suggest me the sample code snippet.
Posted 25-Mar-10 1:01am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

In your MainWindow just set ResizeMode="NoResize"
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

In first (Window) tag on MainWindow.xaml page add
ResizeMode="CanMinimize"
  Permalink  
Comments
CHill60 at 6-Sep-13 8:46am
   
Two years after the question was posted I'm afraid your answer doesn't add much that wasn't already in solutions 1 and 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

You can disable windows border and inside your window add close button only Smile | :) It's not that hard to do
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There is no direct way to disbale the X button (in property ) in a Windows Form, like there is a property for Maximize button called MaximizeBox = false Or Minimize Box = false.
 
Notes: Before you use code, Please add a Close button in your form so that you can close your app.
 
Add the following library
using System.Runtime.InteropServices;
Declare the following as class level variable
const int MF_BYPOSITION = 0x400;
[DllImport("User32")]
private static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlags);
[DllImport("User32")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("User32")]
private static extern int GetMenuItemCount(IntPtr hWnd);

In the Form_Load() event, write the following code
private void Form1_Load(object sender, EventArgs e)
{
IntPtr hMenu = GetSystemMenu(this.Handle, false);
int menuItemCount = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, menuItemCount - 1, MF_BYPOSITION);
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I too was facing this same problem. The solution that i got is:
 
private void Page_Loaded(object sender, RoutedEventArgs e)
{
((NavigationWindow)LogicalTreeHelper.GetParent(this)).ResizeMode = ResizeMode.NoResize;
}

 
If you are using the NavigationWindow(a WPF page is default displayed in a NavigationWindow), we can set the ResizeMode of the NavigationWindow. Smile | :)
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 319
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 230
3 CPallini 205
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 5 Sep 2013
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