Jump to content



Photo

XAML ApplicationBar Click causes XAMLParse exception

xaml windows phone

  • Please log in to reply
1 reply to this topic

#1 James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 13 August 2013 - 21:51

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 System.Windows.ni.dll

 

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) {
                return;
            }
            _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")));
        }

XAML:

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False" x:Name="AppBar">
            <shell:ApplicationBarIconButton IconUri="/Assets/AppBar/transport.play.png" 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" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

C#

private void Refresh_Click(object sender, System.Windows.RoutedEventArgs e)
{
   LoadFeed();
}




#2 OP James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 15 August 2013 - 14:07

Found the issue.

 

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

Correct: Refresh_Click(object sender, EventArgs e)





Click here to login or here to register to remove this ad, it's free!