views:

27

answers:

1

I have UserControl1 and I want to create it's instance and set attached property for it in the code behind of the other UserControl2. The other words, I have in the UserControl2:

<UserControl2>
  <Canvas>
  </Canvas>
</UserControl2>

And I want to do:

<UserControl2>
  <Canvas>
     <UserControl1 Canvas.Left="100" ... />
  </Canvas>
</UserControl2>

How can I create UserControl1 with attached property in code behind of the UserControl2?

+1  A: 
UserControl1 ctrl = new UserControl1();
Canvas.SetLeft(ctrl, 100);
Nir