下面的 Binding 是在一个名为 IEnumerable 的活动上。问题是,在我的 xaml 中......我只想输出数组中的第一个元素。你能按照这些思路做点什么吗:
<Run Text="{Binding activity[0].created_by.name}"></Run>
或者您是否必须为活动 IEnumerable 数组链接另一个数据模板?
这是 ActivityStream 类的属性(我现在注意到它是一个 List..hmm。)
...
[DataMember]
public List<object> activity { get; set; }
...
这是我做 PropertyChanged yada yada 的地方
public IEnumerable<JamesStream> activityStream;
...
private async void LoadActivityStreamSection()
{
activityStreamRepository = new JamesStreamRepository();
var tempActivityStream = await activityStreamRepository.GetAllBySpaceId(space.space_id);
activityStream = tempActivityStream;
ActivityStream = null;
//The Activitiy Stream has a property which is of type List<object> called activity
// In my xaml I just want to be outputting the 1st entry of the List<object> property .created_by_name
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler tempEvent = PropertyChanged;
if (tempEvent != null)
{
// property changed
tempEvent(this, new PropertyChangedEventArgs(propertyName));
}
}
public IEnumerable<JamesStream> ActivityStream
{
get
{
return activityStream;
}
set
{
if (activityStream != value)
{
OnPropertyChanged();
}
}
}