我知道之前已经问过,但我已经尝试过答案了:
并且都不起作用,标题栏文本就在那里,我无法将我的网格移动到窗口的顶部,以便网格占据整个窗口.我被困在这上面了.
窗口的XAML:
<Window x:Class="PlayWPF.TimerSlideWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="" Height="95" Width="641" WindowStyle="None"
ResizeMode="CanResize" AllowsTransparency="False">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Slider Height="42" HorizontalAlignment="Left" Margin="10,14,0,0"
Name="sldTime" VerticalAlignment="Top" Width="495" />
<TextBox FontSize="18" Height="29" HorizontalAlignment="Left"
Margin="510,10,0,0" Name="txtTime" Text="00:00:00"
TextAlignment="Center" VerticalAlignment="Top" Width="93" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud) 当我显示一个WPF窗口时WindowStyle="None",它在使用areo时看起来很棒.
但是,当我使用luna或classic时,它会显示一个约5像素宽的丑陋灰色边框.
当然,如果我设置ResizeMode="NoResize",这个边框消失了,但我希望窗口可以调整大小(ResizeMode="CanResize").
其他非WPF应用程序(实时邮件,即firefox等)不显示此灰色边框,但仍可调整大小.
有没有办法在仍可调整大小的同时删除此边框?
我有一个自定义WPF窗口定义为:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" MinHeight="300" Height="350" MinWidth="600" Width="700" ResizeMode="CanResizeWithGrip" AllowsTransparency="True" WindowStyle="None">
Run Code Online (Sandbox Code Playgroud)
我在网上发现了一个创建阴影的课程,如下所示.即使使用调整大小的抓地力,这也很有效,直到我最大化窗口.一旦我最大化窗口或更改另一个窗口的窗口状态(例如Visual Studio),我就会松开阴影,我无法将其恢复.有任何想法吗?
阴影类:
Public Class DropShadow
Private Shared _handler As EventHandler = New EventHandler(AddressOf window_SourceInitialized)
<DllImport("dwmapi.dll", PreserveSig:=True)> _
Private Shared Function DwmSetWindowAttribute(hwnd As IntPtr, attr As Integer, ByRef attrValue As Integer, attrSize As Integer) As Integer
End Function
<DllImport("dwmapi.dll")> _
Private Shared Function DwmExtendFrameIntoClientArea(hWnd As IntPtr, ByRef pMarInset As Margins) As Integer
End Function
Public Shared Sub DropShadowToWindow(window As Window)
If Not DropShadow(window) Then
AddHandler window.SourceInitialized, _handler …Run Code Online (Sandbox Code Playgroud) 我正在WPF中设计自己的自定义窗口,我一直在尝试实现我以前在WinForms中使用的调整大小功能.由于某种原因,我的WndProc的返回值没有给我正确的结果.
我有一个NativeMethods类用于我所有的WndProc消息和结果:
public class NativeMethods
{
public const int WM_NCHITTEST = 0x84;
public const int HTCAPTION = 2;
public const int HTLEFT = 10;
public const int HTRIGHT = 11;
public const int HTTOP = 12;
public const int HTTOPLEFT = 13;
public const int HTTOPRIGHT = 14;
public const int HTBOTTOM = 15;
public const int HTBOTTOMLEFT = 16;
public const int HTBOTTOMRIGHT = 17;
}
Run Code Online (Sandbox Code Playgroud)
这是我的窗口背后的代码:
public partial class MainWindow : Window
{
const int GripSize = 16; …Run Code Online (Sandbox Code Playgroud) 我希望有人可以在这里指出我正确的方向.我试图将我的模拟时钟应用程序变成无窗口时钟.我搜索了谷歌,但我认为我的问题是我不知道我正在尝试做什么的正确术语.
我的模拟时钟应用程序是一个包含时钟指针的圆圈.这与大多数其他应用程序一样包含在窗口中.我想删除窗口,只有时钟显示在背景上方.我可以在鼠标悬停时调出关闭按钮.或者也许我可以使整个窗口透明,除了时钟和鼠标在上面,我将能够看到窗口并关闭它.
有人有这方面的经验吗?也许某些提示或教程在哪里?
谢谢,
如您所知,当allow transparent属性为true时,窗口的边框被隐藏,我们无法调整窗口的大小。我们仅在将ResizeMode设置为CanResizeWithGrip的情况下才调整窗口的大小,但是解决方案不好,因为我们可以在最大化窗口时调整窗口的大小,并通过窗口的右角而不是所有4个角来更改,因此问题是如何如何在“允许透明”为True的情况下不使用CanResizeWithGrip来重新调整WPF中的窗口大小?
提前致谢!
〜锡
我在 Windows 10 设备和 Windows 7 设备之间有恼人的外观差异。
我正在我的元素中直接使用WindowStyle="None"和。DockPanelWindow
我不明白的是为什么还有边界?为什么按钮、文本框、组合框等的边框是圆形的?
这似乎与Aero有关。有什么方法可以阻止我的应用程序使用 Aero?我假设还有另一个与 Windows 10 相关的演示框架,但不知道强制它叫什么。
将一个BorderBrush是解决最简单的方法?
<Window x:Class="CBD.Presentation.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CBD.Presentation"
Title="CBD" Height="760" Width="944" WindowStartupLocation="CenterScreen"
WindowStyle="None" SizeChanged="Window_SizeChanged" MinWidth="944" MinHeight="760"
Icon="favicon.ico">
<DockPanel x:Name="Root_Window" Background="Black">
<!--Application stuff here -->
</DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
Windows 7 显示:

Windows 10 显示:
一切仍然正常运行,但某些文本框和按钮的设置方式,缺少部分字母。