Sign in to follow this  

XAML ApplicationBar Click causes XAMLParse exception

Recommended Posts

James Rose    38

Hello gang,


I'm writing a Phone app but when I add: Click="Refresh_Click" and attempt to run the app I get this error:


XAMLParseException: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in


The error occurs on InitializeComponent();  When I remove Click="Refresh_Click", the app runs fine.  What dumbass thing am I doing?


EDIT: I have also noticed that if I attempt to access the control after init, even without the code, the object is null.   daHe!!?


Thanks kindy.

        public void InitializeComponent() {
            if (_contentLoaded) {
            _contentLoaded = true;
            System.Windows.Application.LoadComponent(this, new System.Uri("/Great%20American%20Broadcast;component/MainPage.xaml", System.UriKind.Relative));
            this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
            this.TitlePanel = ((System.Windows.Controls.StackPanel)(this.FindName("TitlePanel")));
            this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
            this.feedListBox = ((System.Windows.Controls.ListBox)(this.FindName("feedListBox")));
            this.GABMedia = ((System.Windows.Controls.MediaElement)(this.FindName("GABMedia")));
            this.AppBar = ((Microsoft.Phone.Shell.ApplicationBar)(this.FindName("AppBar")));


        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False" x:Name="AppBar">
            <shell:ApplicationBarIconButton IconUri="/Assets/AppBar/" Text="play" />
            <shell:ApplicationBarIconButton IconUri="/Assets/AppBar/stop.png" Text="stop" IsEnabled="False"/>
            <shell:ApplicationBarIconButton IconUri="/Assets/AppBar/refresh.png" Text="refresh" Click="Refresh_Click" />


private void Refresh_Click(object sender, System.Windows.RoutedEventArgs e)

Share this post

Link to post
Share on other sites
James Rose    38

Found the issue.


Wrong: Refresh_Click(object sender, System.Windows.RoutedEventArgs e)

Correct: Refresh_Click(object sender, EventArgs e)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.