BindableApplicationBarButton Parent

Jan 23, 2013 at 6:43 PM

Hey there,

I just came across this library and so far I'm finding it great. But I'm hitting a block and was wondering if you could help out. In my code I'm trying to get the parent applicationbar (with button.Parent) but it always returns null. The ApplicationBar property is private so I can't access that either. Any ideas?


Jan 23, 2013 at 8:32 PM

The Parent property isn't used there. This is probably the same reason why the standard app bar or app bar button aren't FrameworkElements. My bindable ones are to make them bindable, but that required me to derive from FrameworkElement which has a DataContext property. Unfortunately it also has lots of other properties that won't work here like Parent, Width, Style, etc.

The purpose of the bindable app bar is to use it with MVVM pattern, so the app bar itself shouldn't need to be required and is not exposed by the button class. That said - you can get it by simply getting your page.ApplicationBar property.

Jan 23, 2013 at 11:12 PM

Thanks for clearing that up. I was doing something where I needed the parent by traversing through the visual tree in a separate control. But I ended up changing how I'm doing that. Thanks anyway! :)

Jan 23, 2013 at 11:18 PM

Right, the app bar buttons are not part of the visual tree.