Bug 25694 - xaml binding on toolbarItem.Text Fails
Summary: xaml binding on toolbarItem.Text Fails
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: 1.3.4
Assignee: Bugzilla
URL:
: 26299 ()
Depends on:
Blocks:
 
Reported: 2015-01-03 20:20 UTC by Erik Renaud
Modified: 2015-02-11 06:03 UTC (History)
9 users (show)

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


Attachments
Sample App (4.50 MB, application/octet-stream)
2015-01-05 13:37 UTC, Udham Singh
Details


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:
Status:
VERIFIED FIXED

Description Erik Renaud 2015-01-03 20:20:57 UTC
Given this xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
					   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
					   x:Class="App1.Class1">
  <StackLayout>
    <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
  </StackLayout>
    <ContentPage.ToolbarItems>
    <ToolbarItem Text="{Binding MainText}"  Command="{Binding MainTextCommand}" />
  </ContentPage.ToolbarItems>
</ContentPage>


and this class1

    public partial class Class1
    {
        public Class1()
        {
            InitializeComponent();

            MainText = "initial";
            MainTextCommand = new Command(() =>
            {
                MainText = "changed";

                var inpc = this as INotifyPropertyChanged;
                if (inpc.PropertyChanged != null) inpc.PropertyChanged(this, new PropertyChangedEventArgs("MainText")); //TODO xamarin.forms doesn't seem to be able to accept this binding
            });

            BindingContext = this;
        }

        public string MainText { get; set; }

        public Command MainTextCommand { get; set; }
    }




The result is that even though PropertyChanged is raised for the binding corresponding to the Text property of the ToolbarItem, the change doesn`t propagate.
Comment 1 Udham Singh 2015-01-05 13:37:24 UTC
Created attachment 9241 [details]
Sample App

Hi Erik, 

We have tried to reproduce this issue with the help of code provided in bug description but not able to reproduce this. Could you please provide a sample app and screencast that demonstrate this issue? So that we can reproduce this issue at our end.

I am attaching a sample app which I have created to reproduce this issue. Please have a look on this and let me know if I am missing any thing.

Thanks!
Comment 2 Erik Renaud 2015-01-05 13:52:12 UTC
You can try the following project 

https://onedrive.live.com/redir?resid=3BFB6277842BACCE!158319&authkey=!AIyt2qtfr5wkrfY&ithint=file%2czip

and try to run the WinPhone app.

Regards, Erik.
Comment 3 Jason Smith [MSFT] 2015-01-26 13:08:12 UTC
*** Bug 26299 has been marked as a duplicate of this bug. ***
Comment 4 Jason Smith [MSFT] 2015-02-06 16:10:10 UTC
Should be fixed in 1.3.4-pre1
Comment 5 Ram Chandra 2015-02-11 06:03:40 UTC
I have checked this issue with following builds:

Xamarin.Forms.1.3.4.6328-pre2
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin   3.9.293.0 (080a254)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.1.0 (3b3ef438017c7ecf486defa9e01567a5f2b3cb2a)
Xamarin.iOS Unified Migration   1.0

When I deployed the attached project on windows emulator and press the toolbar item, the PropertyChanged is raised and the changes also applied to the toolbar item.

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

This issue has been fixed. Hence I am closing this issue.