模糊BitmapCache

时间:2014-03-29 19:22:03

标签: c# wpf .net-4.0

问题

如下图所示,当我将ScrollViewer内容的高度设置为1056px(100%)时,文字和线条都很清晰。

100X Zoom

但是,当我将内容的高度设置为6336px(600%)时,文字和线条确实模糊不清。

600X Zoom

我使用默认设置将内容的CacheMode属性设置为BitmapCache。我不确定这是否适用,但高度由Binding控制。

问题

有没有办法以某种方式刷新CacheMode?我知道对子布局属性的更改应该触发自动刷新,但由于某些原因,这在我的情况下不起作用。或者问题可能只是显卡?

我尝试过什么

  • 我将CacheMode设置为null,然后设置为新的BitmapCache
  • 我设置了RenderAtScale。{/ li>的BitmapCache属性
  • 我拨打了InvalidateProperty(CacheModeProperty)UpdateLayout

守则

<Friction:FrictionScrollViewerControl x:Class="App.Controls.Panes.Calendar.Day.HourlyClockChartDay"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:controls="clr-namespace:App.Controls.WeekView"
        xmlns:Friction="clr-namespace:App.Controls.Friction" mc:Ignorable="d" d:DesignHeight="400"
        d:DesignWidth="300" Loaded="ClockChart_Loaded" Focusable="False" VerticalScrollBarVisibility="Visible"
        PreviewMouseWheel="scrollViewer_PreviewMouseWheel" VerticalSnapToValue="22">
    <Grid x:Name="grid" Height="1056">
        <Grid.CacheMode>
            <BitmapCache />
        </Grid.CacheMode>
        <Grid x:Name="clockGrid" Height="{Binding Height, ElementName=grid, Mode=OneWay}" IsHitTestVisible="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="clockGridCol0" Width="50" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <controls:ClockGrid x:Name="clockGridBg" Grid.Column="1" Grid.RowSpan="96" />
        </Grid>
        <Grid x:Name="radioGrid" Height="{Binding Height, ElementName=grid, Mode=OneWay}" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding Width, ElementName=clockGridCol0, Mode=OneWay}" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.Resources>
                <Style TargetType="RadioButton">
                    <Setter Property="GroupName" Value="_dayGridRadios" />
                    <Setter Property="Margin" Value="0,0,0,1" />
                    <Setter Property="Grid.Column" Value="1" />
                    <Setter Property="ClickMode" Value="Press" />
                    <EventSetter Event="Checked" Handler="RadioButton_Checked" />
                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="RadioButton_PreviewMouseLeftButtonDown" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="RadioButton">
                                <Rectangle x:Name="rect" Fill="Transparent" />
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsChecked" Value="True">
                                        <Setter Property="Fill" TargetName="rect" Value="{DynamicResource CheckedDate}" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Grid.Resources>
        </Grid>
        <Grid x:Name="itemsGrid" Height="{Binding Height, ElementName=grid, Mode=OneWay}" Margin="0,0,11,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding Width, ElementName=clockGridCol0, Mode=OneWay}" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
        </Grid>
        <Border x:Name="currentTime" Background="{DynamicResource TimeSliderBackground}"
                BorderBrush="{DynamicResource TimeSliderBorder}" BorderThickness="0,1" Height="3"
                VerticalAlignment="Top" Visibility="Collapsed" IsHitTestVisible="False" />
        <Border BorderBrush="#FFE1E1E1" BorderThickness="0,0,1,0" IsHitTestVisible="False" />
    </Grid>
</Friction:FrictionScrollViewerControl>

设置高度的C#:

grid.Height = (int)((int)(1056 * percent) / 528) * 528;

0 个答案:

没有答案