AutomationProperties.AccessKey="Number2" looked like the perfect property to add on my 2 button for instance, but I was disappointed to find out that nothing supported it.
In the end, I needed to have a base class that did some of the handling for my keyboard mapping to the access keys, as I don’t want to write that code over and over again (actually, I don’t want to debug and keep parallel copies up to date, but I digress).
So, what better way than a base class I thought.
So, here’s what I did. I had my keyboard like control based on a UserControl. Why not just change the base class to SpecializedUserControl like this:
Then, I can create a new user control, and base it on this new base class like this:
and declare it in XAML like this:
Interestingly, while writing this, I was disappointed to find that everything worked fine, and I wasn’t getting the error I got in my actual code.
Here’s how I instantiated the control on my page:
Not to be beaten (as it really didn’t appear to work in my code), I started porting across bits of my implementation, a feature of which was that I needed a property to attach to controls in my implementation that could hold a function to call when the AccessKey was pressed, so I did it like this in SpecializedUserControl:
Now when I run the same program, I get this error:
Anyone have any idea why adding a declaration of an attached property breaks it in this way?