开发者

Controls blurred over aero glass after resizing

I am building a form using aero-glass as background, as I described in "Windows Aero Glass background is broken after hibernate. How can I solve this?". The window has ResizeMode="NoResize" SizeToContent="WidthAndHeight" set.

There is a Grid, with some fixed columns and one variable column with an element. This element is set to be visible and collapsed. My window should expand and contract by self, what works perfectly.

My problem is that after rezising all controls get blurred about 1 pixel in every dimension. After regenerating the previous size by toggeling the elements visibly-state this blurr disappeares. I got to know already, that it appears everytime the window ist programmly resized. If it is resized by the user, by just draging the corner (ofcourse without the ResizeMode="NoResize") the controls stay clear.

SnapsToDevicePixels="True" seems to have no effect on this behaviour.

If Aero Glass is disabled everything works perfectly and stays clear.

I am looking forward to recieve your suggestions.

Thank you in advance.

Edit:

Example:

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.
}


You can use Invalidate() method to redraw the window or the control after you resize it programmatically... Possibly override the method for resizing would make it easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜