我无法绑定全景标题。任何想法怎么样?其他绑定工作正常。
<Grid x:Name="ContentPanel">
<phone:Panorama x:Name="pnBookDetails">
<phone:Panorama.TitleTemplate>
<DataTemplate>
<TextBlock Text="{Binding BookTitle, Mode=OneWay}" />
</DataTemplate>
</phone:Panorama.TitleTemplate>
.cs文件
await bookdetailsvm.GetBookDetails(Convert.ToInt64(bookid));
ContentPanel.DataContext= bookdetailsvm.booksdetailsObject; returns Books 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;
}
}
答案 0 :(得分:2)
它不起作用,因为标题没有绑定。
正确的语法是:
<phone:Panorama x:Name="pnBookDetails" Title="{Binding BookTitle, Mode=OneWay}">
<phone:Panorama.TitleTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" />
</DataTemplate>
</phone:Panorama.TitleTemplate>
答案 1 :(得分:1)