Bug 25908 - Unhandled NullReferenceException setting Activated property of ToolbarItem on xaml.
Summary: Unhandled NullReferenceException setting Activated property of ToolbarItem on...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-11 10:28 UTC by FernandoVM
Modified: 2015-02-10 08:22 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Sample App (4.50 MB, application/octet-stream)
2015-01-12 11:02 UTC, Udham Singh
Zip Xamarin Logs (6.89 KB, application/octet-stream)
2015-01-12 11:05 UTC, Udham Singh

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description FernandoVM 2015-01-11 10:28:52 UTC
A exception is throwed "at Xamarin.Forms.Xaml.BaseValueNode.SetPropertyValue(object,Xamarin.Forms.Xaml.XmlName,object)" when we try set an event handler to Activated property of ToolbarItem.

XAML sample file:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" 
    <ContentPage Title="MyApp Master">
      <StackLayout Spacing="0" Padding="0, 20, 0, 0" VerticalOptions="Start">
        <Label Text="Master page!" VerticalOptions="Center" HorizontalOptions="Center" />
    <ContentPage Title="MyApp Detail">      
        <ToolbarItem Name="Menu4" Activated="OnClick" Order="Primary" Priority="0" />
        <StackLayout Spacing="0" Padding="0, 20, 0, 0" VerticalOptions="Start">
          <Label Text="Detail page!" VerticalOptions="Center" HorizontalOptions="Center" />

Code-behind method:
void OnClick(object sender, EventArgs e)
    ToolbarItem tbi = (ToolbarItem)sender;
    this.DisplayAlert("Selected!", tbi.Name, "OK", "Cancel");

I did not found a workaround using xaml, we need set the event handler in code-behind.
Comment 1 Udham Singh 2015-01-12 11:02:09 UTC
Created attachment 9320 [details]
Sample App

I have checked this issue and able to reproduce the reported behaviour. To reproduce this issue I have followed the steps mentioned below : 

1. Create a new mobile app via 'File > New > Project... > Mobile Apps > Blank App (Xamarin.Forms Potable)'.
2. Add a new xaml page (Forms Xaml Page) in PCL project.
3. Implement the code provided in bug description in newly added xaml page.
4. Set android project as start-up project and run the app, and got the issue.

Screencast : http://www.screencast.com/t/J9ZKGlCUdE

Application output for android app : https://gist.github.com/Udham1/dc07fbd46552c92ccf24
Application output for iOS app : https://gist.github.com/Udham1/cae9efbfc1b069ba544c

Note : I am getting the same behaviour with iOS app. I am attaching a sample app which I have created to reproduce this issue.

Environment Info :

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin (10cfd178d55287f09c85f5a1e604dfe20889a40f)

Xamarin.iOS Build Host :
Comment 2 Udham Singh 2015-01-12 11:05:25 UTC
Created attachment 9321 [details]
Zip Xamarin Logs

An update to the comment 1 : Attaching Zip Xamarin Logs.
Comment 3 Rui Marinho 2015-01-26 12:11:57 UTC
This is fixed in the public 1.3.1 release
Comment 4 Udham Singh 2015-02-10 08:22:24 UTC
I have checked this issue with Xamarin.Forms Version and
observed that now this is working fine. Hence I am closing this issue.

Please refer the screencast : http://www.screencast.com/t/ldKFMsUemSj

Environment Info :

Xamarin.Forms :

Windows 8
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin (080a254)

Xamarin.iOS Build Host