ContentControl旋转装饰器渲染

kra*_*ew4 12 .net c# wpf

我最近偶然发现了以下问题.在我的WPF应用程序中,我实现了很少的设计器,你可以在画布上放置元素,移动,缩放和旋转它们.在网上搜索时,我发现了以下解决这个问题的方法http://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1.这个解决方案通过System.Windows.Controls.Primitives.Thumb类实现移动,缩放和旋转,所以我想我只是将这个解决方案调整到我的应用程序并继续前进.问题是,虽然在我的机器上一切都很好,但在其他机器上存在一些渲染问题.我已经对我所说的做了一个屏幕截图:

截图

我正在使用Windows 7,即使我在另一个Window 7上运行我的应用程序,它也会出错.我在我的机器上使用窗口xp和其他兼容性设置运行我的应用程序,但我无法重现此错误.这是什么以及我可能做错了什么?

这是我用于内容控件样式的xaml文件

 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:s="clr-namespace:COMPANY.WPUI.LayoutDesignModel.Thumbs">
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="MoveThumb.xaml"/>
        <ResourceDictionary Source="ResizeDecorator.xaml"/>
        <ResourceDictionary Source="RotateDecorator.xaml"/>
      </ResourceDictionary.MergedDictionaries>

      <Style x:Key="DesignerItemStyle" TargetType="ContentControl">
        <Setter Property="MinHeight" Value="50"/>
        <Setter Property="MinWidth" Value="50"/>    
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>       
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="ContentControl">
              <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                <Control Name="RotateDecorator"
                         Template="{StaticResource RotateDecoratorTemplate}"
                         Visibility="Collapsed"/>
                <s:MoveThumb Template="{StaticResource MoveThumbTemplate}"
                             Cursor="SizeAll"/>
                <Control x:Name="ResizeDecorator"
                         Template="{StaticResource ResizeDecoratorTemplate}"
                         Visibility="Collapsed"/>
                <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
              </Grid>
              <ControlTemplate.Triggers>
                <Trigger Property="Selector.IsSelected" Value="True">
                  <Setter TargetName="ResizeDecorator" Property="Visibility" Value="Visible"/>
                  <Setter TargetName="RotateDecorator" Property="Visibility" Value="Visible"/>
                </Trigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    </ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)

这是RotateDecorator.xaml文件,它恰好会导致问题:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:COMPANY.WPUI.LayoutDesignModel.Thumbs">

    <Style TargetType="{x:Type s:RotateThumb}">        
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type s:RotateThumb}">
                    <Grid Width="30" Height="30">                        
                        <Ellipse Width="30" Height="30" Fill="#B0B0BB" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="RotateDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid>
            <s:RotateThumb Margin="-18,-18,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
            <s:RotateThumb Margin="0,-18,-18,0" VerticalAlignment="Top" HorizontalAlignment="Right" />
            <s:RotateThumb Margin="0,0,-18,-18" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
            <s:RotateThumb Margin="-18,0,0,-18" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
        </Grid>
    </ControlTemplate>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)

Pan*_*anh 0

看到这样的东西我第一个想到的就是显卡。某些显卡可能会出现一些奇怪的行为,特别是如果它们的驱动程序未正确安装/最新。