小编kra*_*ew4的帖子

ContentControl旋转装饰器渲染

我最近偶然发现了以下问题.在我的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> …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf

12
推荐指数
1
解决办法
623
查看次数

标签 统计

.net ×1

c# ×1

wpf ×1