如何禁用不在窗口中的WPF应用程序页面中的最大化按钮 [英] How to disable maximize button in a WPF appication page not in a window
问题描述
我想在WPF应用程序页面而不是WPF应用程序窗口中禁用最大化按钮
当我在Google中搜索时,可以使用以下方法在WPF窗口中禁用最大化按钮
代码段如下
Window.WindowStyle = WindowStyle.None
但是在WPF页面中不起作用
显示错误.
在WPF页面中,有WindowStyleProperty而不是WindowStyle
它显示错误为
错误1:无法将静态只读字段分配给它(在静态构造函数或变量初始化程序中除外)
错误2:无法将类型"System.Windows.WindowStyle"隐式转换为"System.Windows.DependencyProperty"
那么如何在WPF页面中禁用最大化按钮
那我该怎么实现
向我建议任何示例代码片段....
预先感谢.........
I want to disable the maximize button in WPF application page, not in a WPF application window
When I searched in Google, it is available methods for disabling the maximize button in WPF window
The code snippet is as follows
Window.WindowStyle= WindowStyle.None
But is not working in WPF page
It is showing errors.
In WPF page there is WindowStyleProperty instead of WindowStyle
and it is showing errors as
Error 1:A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)
Error 2: Cannot implicitly convert type ''System.Windows.WindowStyle'' to ''System.Windows.DependencyProperty''
So how can I disable the maximize button in WPF page
Then how can I implement it
Suggest me any sample code snippet....
Advance thanks.........
推荐答案
在您的XAML中添加resizeMode ="canMinimize".
Add resizeMode ="canMinimize" in your XAML.
您可以将窗口样式设置为没有边框,这就是您要尝试做的,但是您做错了.您需要使用此窗口,而不是Window,因为否则您将尝试访问错误的内容.然后,您将根本没有任何按钮,并且需要添加所需的按钮.我们也必须为我们的应用执行此操作.
You can set the window style to not have a border, which is what you''re trying to do, but you''re doing it wrong. You need to use this, not Window, because otherwise you''re trying to access the wrong thing. Then you''ll have no buttons at all, and will need to add the ones you want. We had to do this for our app, also.
这篇关于如何禁用不在窗口中的WPF应用程序页面中的最大化按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!