2012-10-10 13 views
10

私は最近、次の問題を偶然見つけました。私のWPFアプリケーションでは、小さなデザイナーを実装しました。キャンバス上に要素を配置し、移動、拡大縮小、回転することができます。ウェブを検索しているうちに、この問題の解決策を見つけたhttp://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1。このソリューションは、System.Windows.Controls.Primitives.Thumbクラスで移動、スケーリング、回転を実装しているので、私はこのソリューションを自分のアプリケーションに合わせて移動すると思っていました。問題は、私のマシンではすべて問題ないが、他のマシンではレンダリングの問題がある。ContentControlデコレータレンダリングを回転させる

screenshot

私は私が他のウィンドウ7に私のアプリを実行し、それはまた間違ってレンダリングされていてもWindows 7のを使用しています:私は、私が言っているかのスクリーンショットを作りました。私はウィンドウXPと私のマシン上の他の互換性の設定で私のアプリを実行するが、私はこのバグを再現することができませんでした。これはどういうことなのですか?

これは私が

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

Aスタイリングコンテンツ制御のために使用しています私のXAMLファイルで、これは問題を引き起こすことが起こる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> 
+0

こんにちはkrajew4、あなたの質問にあなたのコードを含める必要があります。 – Surfbutler

+0

codeprojectサンプルはすべてのマシンで正しく動作しますか? – Surfbutler

答えて

0

私が考える最初の事このようなものを見るときはいつでも、グラフィックスカードです。特定のグラフィックスカードで、特にドライバが正しくインストールされていない/最新のものである場合、いくつかの奇妙な動作が発生する可能性があります。

0

これはMergedDictionariesによって発生します。ダイアグラムデザイナープロジェクトは、移動、サイズ変更、および回転のアクションを3つの別々の辞書に分割します。スクリーンショットから、リサイズサムがロードされていることがわかります。私の場合は動きの動きもうまくいきましたが、質問のように回転の親指は表示されませんでした。エラーはスローされませんでしたが、Snoopで調べると、回転辞書が見つかりませんでした。

このソリューションは、私が上にカバーしてきたことを拡張:解決するためにhttps://stackoverflow.com/a/17083360/978622

:単一のリソース・ディクショナリにリソースディクショナリを組み合わせます。

関連する問題