我有以下窗口:
class SiteMiddleware(object):
def process_request(self, request):
try:
try:
current_site = Site.objects.get(domain=request.get_host())
except Site.DoesNotExist:
current_site = Site.objects.get(id=settings.SITE_ID)
request.current_site = current_site
if current_site.domain in settings.HOST_MIDDLEWARE_URLCONF_MAP:
request.urlconf = settings.HOST_MIDDLEWARE_URLCONF_MAP[str(current_site)]
except Exception as ex:
print('Error: %s' % ex)
在我的App.xaml中,我有以下BorderlessWindow风格:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen" ShowInTaskbar="True"
Style="{StaticResource BorderlessWindow}" SizeToContent="WidthAndHeight">
<Grid>
</Grid>
</Window>
要使应用程序运行,您需要对Microsoft.Windows.Shell的引用。并且要完整:我们正在使用.NET Framework 4.0和VS 2015。
我已设置<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="BorderlessWindow" TargetType="{x:Type Window}">
<Setter Property="MinWidth" Value="325" />
<Setter Property="MinHeight" Value="240" />
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome CaptionHeight="32"
GlassFrameThickness="0"
ResizeBorderThickness="12" />
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>
以获得一个较小的窗口,但是当我这样做时,我会得到一个黑色&#34;阴影&#34;在右边和底部。使用snoop,我看到MainWindow设置为MinHeight和MinWidth,但其中的Border不是。
为什么内容也没有重新调整大小?通过使用鼠标调整窗口大小来更新窗口时,窗口看起来像预期的那样。
答案 0 :(得分:1)
您可以为ContentRendered添加处理程序,并在呈现内容后强制重绘它。你可以把它挂在xaml或后面的代码中,这里是代码背后的。
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ContentRendered += OnContentRendered;
}
private void OnContentRendered(object sender, EventArgs eventArgs)
{
InvalidateVisual();
}
}