2011-01-29 5 views

答えて

0

、しかし、Silverlightの4.0は、今あなたができる、依存関係オブジェクトに結合する能力を追加しました を、Dependency Objectから継承する変換のようなものにバインドします。 BindingOperationsクラスを使用すると、DependancyObject、バインドするプロパティ、およびバインディング式を渡すことができます。

//w is a UIElement 
//rot is a rotate transform 

w.RenderTransform = rot; 

Binding b = new Binding("Value") { Source = RotationSlider }; 
BindingOperations.SetBinding(rot, RotateTransform.AngleProperty, b); 
1

TransformクラスにはSetBinding()というメソッドがありません。 は、ここでは、この問題の回避策です:与えたあなたは、実行時にXAMLに負荷によって、ANSERのVorrtexでこれを行うことができます

var rect = new Rectangle { Width = 100, Height = 60, Fill = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)) }; 

var t = 
    XamlReader.Load("<RotateTransform xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "+ 
      "Angle='{Binding Value, ElementName=slider1}'/>") as RotateTransform; 
rect.RenderTransform = t; 
関連する問題