我正在使用航空玻璃作为背景构建一个表单,正如我在“ Windows Aero Glass 背景在休眠后损坏。我该如何解决这个问题? ”中所述。窗口已ResizeMode="NoResize" SizeToContent="WidthAndHeight"
设置。
有一个网格,有一些固定列和一个带有元素的可变列。此元素设置为可见和折叠。我的窗户应该会自行扩展和收缩,什么效果都很好。
我的问题是,调整大小后,所有控件在每个维度上都模糊了大约 1 个像素。通过切换元素可见状态重新生成以前的大小后,这种模糊消失了。我已经知道了,它会在每次以程序方式调整窗口大小时出现。如果用户调整了它的大小,只需拖动角(当然没有ResizeMode="NoResize"
),控件就会保持清晰。
SnapsToDevicePixels="True"
似乎对这种行为没有影响。
如果 Aero Glass 被禁用,一切都会完美运行并保持清晰。
我期待收到您的建议。
先感谢您。
编辑:
例子:
XAML:
<Window x:Class="glass_sample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SampleWindow"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Loaded="Window_Loaded"
Background="{StaticResource {x:Static SystemColors.ActiveCaptionBrushKey}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="Toggle"
Click="Button_Click" />
<Button IsEnabled="False"
Grid.Column="1"
Margin="5"
Content="Expanded"
Visibility="Collapsed"
Name="expand" />
</Grid>
</Window>
CS:
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.expand.Visibility = (this.expand.Visibility == System.Windows.Visibility.Visible) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
GlassHelper.GlassFrame(this);
// this is my aero-glass class. It extends glass over clientarea and repeats
// this when WM_THEMECHANGED or WM_DWMCOMPOSITIONCHANGED is recieved.
}