开发者

Making control with attached property in code behind (WPF)

开发者 https://www.devze.com 2023-01-06 14:55 出处:网络
I have UserControl1 and I want to create it\'s instance and set attached property for it in the code behind of the other UserCo开发者_运维百科ntrol2.

I have UserControl1 and I want to create it's instance and set attached property for it in the code behind of the other UserCo开发者_运维百科ntrol2. 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?


UserControl1 ctrl = new UserControl1();
Canvas.SetLeft(ctrl, 100);
0

精彩评论

暂无评论...
验证码 换一张
取 消