Click here to Skip to main content
12,948,566 members (62,233 online)
Rate this:
 
Please Sign up or sign in to vote.
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 0: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 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 :) 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. :)
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,419
CHill60 3,275
Maciej Los 2,778
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 5 Sep 2013
Copyright © CodeProject, 1999-2017
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