I’ve created a custom UserControl which is some kind of virtual keyboard button. I’m looking for the following functionally:
- Any Panel should contain a collection of all it’s keyboard button childs.
- Any other control which is also a child of this Panel should be able to enumerate the keyboard buttons of his parent.
It isn’t the big problem to achieve this functionally. I could create an Attached-DependencyProperty of type List and manually manage this list. The problem about this approach would be, that it’s pretty error prone and inconvenient.
Is there any possibility to automatically attach the keyboard button at creation time to the AttachedProperty of the parent?
I’ve already created a quite good solution for my problem. The following code shows my implementation:
I’m generally not programming in .NET, but – from time to time – I’m “forced” to create some tools with it. However, some of you guys may know how I can remove a weakness of this code: It doesn’t support the VisualStudio or Expression Blend Designer. Thus, the controls cannot be modified or even seen at design-time.