I am trying to create an application panel in code for WinPhone7. The XAML that does this is as follows:
<PhoneApplicationPage.ApplicationBar>
<shellns:ApplicationBar Visible="True" IsMenuEnabled="True">
<shellns:ApplicationBar.Buttons>
<shellns:ApplicationBarIconButton IconUri="/images/appbar.feature.search.rest.png" />
</shellns:ApplicationBar.Buttons>
</shellns:ApplicationBar>
</PhoneApplicationPage.ApplicationBar>
So, I thought I just rewrote it in C #:
var appbar = new ApplicationBar();
var buttons = new List<ApplicationBarIconButton>();
buttons.Add(new ApplicationBarIconButton(new Uri("image.png", UrlKind.Relative));
appbar.Buttons = buttons;
The only problem is that the property Buttonsdoes not have an accessory set and is defined as follows:
public sealed class ApplicationBar {
public IList Buttons { get; }
}
How can this be done in XAML and not in C #? Is there a special way to create objects using this syntax?
More importantly, how can I recreate this in code?
source
share