2011-07-07 12 views
1

を持っている:私はdesignAreaの子供たちからmyBorder取得するときUI要素に関連付けられた動作にアクセスするにはどうすればよいですか?例えば、私はこれを

Border myBorder = new Border(); 
... 
designArea.Children.Add(myBorder); 

ResizeAndMoveBehavior b = new ResizeAndMoveBehavior(); 
b.CurrentProperties = thisButtonProperties; 
b.Attach(myBorder); 

は今どのように私はmyBorderに添付行動のCurrentPropertiesにアクセスすることができますか?

答えて

2

あなたの動作を非標準的な方法で接続しています。つまり、接続された動作を後で戻す方法はありません。しかし、あなたが標準的なやり方をすれば、この情報を得ることができます。ここでは、行動の管理方法の例を示します。

using System.Windows.Interactivity; 

// Add a behavior. 
Interaction.GetBehaviors(myBorder).Add(b); 

// Get all behaviors of an object. 
BehaviorCollection behaviors = Interaction.GetBehaviors(myBorder); 

// Get a specific type of behavior. 
ResizeAndMoveBehavior myBehavior = (ResizeAndMoveBehavior)behaviors 
    .Where(b => b is ResizeAndMoveBehavior).Single(); 
+0

私はちょうど初心者ですから、あなたの答えは大いに役立ちました。どうもありがとうございます。 – Dmitriyz

関連する問題