本文介绍了如何创建一个WPF窗口,不能够仅通过把手被调整的边界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您设置 ResizeMode =CanResizeWithGrip在一个WPF 窗口则调整大小握显示在低右侧角球,如下:

如果您设置 WindowStyle =无以及标题栏消失,但是灰斜边保持,直到您设置 ResizeMode =NoResize 。不幸的是,设置属性的组合,调整大小的抓地力也消失了。

我已经覆盖了窗口控件模板通过自定义风格。我想指定窗口自己的边界,而我不需要用户能够从四面调整窗口的大小,但我确实需要一个调整大小的抓地力。

有人细节一个简单的方法能满足所有这些标准?

  1. 不要窗口边框除了一个我指定自己在一个控件模板
  2. 不要有一个工作在右下角调整的抓地力。
  3. 不要标题栏。
解决方案

如果您设置了窗口 AllowsTransparency 属性(即使没有设置任何透明度值)的边界消失,你只能通过抓调整。

 <窗​​口
    的xmlns =htt​​p://schemas.microsoft.com/winfx/2006/xaml/$p$psentation
    的xmlns:X =htt​​p://schemas.microsoft.com/winfx/2006/xaml
    WIDTH =640高度=480
    WindowStyle =无
    AllowsTransparency =真
    ResizeMode =CanResizeWithGrip>

    <! - 内容 - >

< /窗>
 

结果是这样的:

If you set ResizeMode="CanResizeWithGrip" on a WPF Window then a resize grip is shown in the lower right corner, as below:

If you set WindowStyle="None" as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode="NoResize". Unfortunately, with this combination of properties set, the resize grip also disappears.

I have overridden the Window's ControlTemplate via a custom Style. I want to specify the border of the window myself, and I don't need users to be able to resize the window from all four sides, but I do need a resize grip.

Can someone detail a simple way to meet all of these criteria?

  1. Do not have a border on the Window apart from the one I specify myself in a ControlTemplate.
  2. Do have a working resize grip in the lower right corner.
  3. Do not have a title bar.
解决方案

If you set the AllowsTransparency property on the Window (even without setting any transparency values) the border disappears and you can only resize via the grip.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="640" Height="480"
    WindowStyle="None"
    AllowsTransparency="True"
    ResizeMode="CanResizeWithGrip">

    <!-- Content -->

</Window>

Result looks like:

这篇关于如何创建一个WPF窗口,不能够仅通过把手被调整的边界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 08:45