简体   繁体   中英

windows phone 8 panorama titlebinding

i am not able to bind to the panorama title . any idea how? other binding are working perfectly.

 <Grid x:Name="ContentPanel">
 <phone:Panorama x:Name="pnBookDetails">
 <phone:Panorama.TitleTemplate>
 <DataTemplate>
    <TextBlock Text="{Binding BookTitle, Mode=OneWay}"  />
 </DataTemplate>
 </phone:Panorama.TitleTemplate>

.cs file

await bookdetailsvm.GetBookDetails(Convert.ToInt64(bookid));
ContentPanel.DataContext= bookdetailsvm.booksdetailsObject;  returns Books object

book object

 public class Books : INotifyPropertyChanged
{
    private long _BookId = 0;
    public long BookId
    {
        get
        {
            return _BookId;
        }
        set
        {
            _BookId = value;
            RaisePropertyChanged("BookId");
        }
    }

    private string _ISBN = string.Empty;
    public string ISBN
    {
        get
        {
            if (string.IsNullOrEmpty(_ISBN))
            {
                return "No ISBN found";
            }
            else
            {
                return _ISBN;

            }
        }
        set
        {
            _ISBN = value;
            RaisePropertyChanged("ISBN");
        }
    }

    private string _BookTitle = string.Empty;
    public string BookTitle
    {
        get
        {
            if (_BookTitle.Length > 35)
            {
              return _BookTitle.Substring(0, 35) + "...";
           }
            else
                return _BookTitle;
        }
        set
        {
            _BookTitle = value;
        }
    }

It does not work because the title is not binded.

The right syntax is:

<phone:Panorama x:Name="pnBookDetails" Title="{Binding BookTitle, Mode=OneWay}">
    <phone:Panorama.TitleTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding }" />
    </DataTemplate>
 </phone:Panorama.TitleTemplate>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM