【问题标题】:Hide the default resizegrip in wpf在 wpf 中隐藏默认的 resizegrip
【发布时间】:2012-12-24 06:17:15
【问题描述】:

是否可以隐藏 wpf 中的默认调整大小手柄,我有一个自定义窗口,侧面没有手柄,目前正在使用:

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="100" Width="200" ResizeMode="CanResizeWithGrip">
    <Grid></Grid>
</Window>

我知道可以只更改ResizeMode="CanResize",但这是我能想到的调整窗口大小的唯一方法。

【问题讨论】:

  • 我不明白 - 您提出的使用 CanResize 的解决方案有什么问题。我相信它和 CanResizeWithGrip 之间的唯一区别是抓地力。
  • 我没有使用删除 CanResize 句柄的窗口边框,但我设法创建了一个类,其中包含八个矩形作为参数用作句柄。

标签: c# wpf resizegrip


【解决方案1】:

是的,您可以从窗口中取出默认的调整大小夹点。您需要覆盖 WindowTemplate。以下是您在 XAML 中的操作方式:

<Window x:Class="MyNamespace.MyWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None" 
        ResizeMode="CanResizeWithGrip"
        AllowsTransparency="True">
    <Window.Template>
        <ControlTemplate>
            <Border>

            </Border>
        </ControlTemplate>
    </Window.Template>
</Window>

“边框”内将包含您需要在窗口中显示的所有内容(例如文本框)。然后,如果您想要自定义 ResizeGrip,您也可以定义它。希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2010-10-05
    • 2018-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    • 2016-05-12
    • 2014-08-23
    相关资源
    最近更新 更多