2009-07-09 8 views
3

私のコードからぼやけています。問題/バグを追跡できません。ここに私のコードビットが...私は再びポストを編集し 読み取り専用状態であるため、オブジェクト「ID」のプロパティを設定できません。

private void DoArrange() 
    { 
     Point center = new Point((this.Width - ItemSize)/2, (this.Height - ItemSize)/2); 
     double radiusX = center.X; 
     double radiusY = center.Y; 
     double scale = ScalePerspective; 

     for (int i = 0; i < Children.Count; i++) 
     { 
      UIElement item = Children[i]; 
      double radians = (double)item.GetValue(CarouselPanel.AngleProperty); 

      Point p = new Point(
           (Math.Cos(radians) * radiusX) + center.X, 
           (Math.Sin(radians) * radiusY) + center.Y 
           ); 

      if (item.RenderTransform == null) 
      { 
       item.RenderTransform = new MatrixTransform(); 
       item.RenderTransformOrigin = new Point(0.5, 0.5); 
      } 
      MatrixTransform mt = item.RenderTransform as MatrixTransform; 
      double scaleMinusRounding = p.Y/(center.Y + radiusY); 
      double scaleX = Math.Min(scaleMinusRounding + scale, 1.0); 
      double scaleY = Math.Min(scaleMinusRounding + scale, 1.0); 
      Matrix mx = new Matrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); 

      *** mt.Matrix = mx; *** 

      item.RenderTransform = mt; 

      int zIndex = (int)((p.Y/base.Height) * 50); 
      item.SetValue(Canvas.ZIndexProperty, zIndex); 
      Rect r = new Rect(p.X, p.Y, ItemSize, ItemSize); 
      item.Arrange(r); 
     } 
    } 

..から発生したエラー*** mt.Matrix = MX。 ***ステートメント..

私はWPF(win)アプリケーションを使用しています。代わりに、読み取り専用のマトリックスプロパティに割り当てるの

+0

エラーは何ですか? – AlbertoPL

答えて

5

、これを試してください。

のUIElementのRenderTransformプロパティは、最初の代わりにヌルの、そのIsSealedとIsFrozen特性の両方に該当するMatrixTransformインスタンスとして割り当てられ
item.RenderTransform = new MatrixTransform(mx); 
+0

私はマウスの位置に画像をズームすることに問題があり、検索にかなりの時間を費やしました。他のソリューションと一緒に私はそれが4行のコードでトリックを見つけた!ありがとう! – EpiGen

1

参照。それは気づかれるべきです。

関連する問題