• 0

XAML ApplicationBar Click causes XAMLParse exception


Question

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();
}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Found the issue.

 

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

Correct: Refresh_Click(object sender, EventArgs e)

Link to comment
Share on other sites

This topic is now closed to further replies.