J'essaie de naviguer vers un élément spécifique dans ListCollectionView en fonction de la valeur de la propriété Date de SelectedDay.Accédez à un élément spécifique dans ListCollectionView
VM
private Day _selectedDay;
public Day SelectedDay // the Name property
{
get { return _selectedDay; }
set { _selectedDay = value; RaisePropertyChanged(); }
}
public ObservableCollection<ShootingDay> AllShootingDayInfo {get; set;}
private ListCollectionView _shootingDayInfoList;
public ListCollectionView ShootingDayInfoList
{
get
{
if (_shootingDayInfoList == null)
{
_shootingDayInfoList = new ListCollectionView(AllShootingDayInfo);}
return _shootingDayInfoList;
}
set
{
_shootingDayInfoList = value; RaisePropertyChanged();
}
}
L'objet <Day>
a une propriété de Date
et je veux que pour correspondre à la Date
propriété dans le <ShootingDay>
objet pour que je puisse accéder à l'élément dans les ShootingDayInfoList
où SelectedDay.Date
matchs Date
de l'article à l'intérieur ShootingDayInfoList
.
J'ai essayé mais cela ne fonctionne pas car l'élément sélectionné ne fait pas partie du même objet.
ShootingDayInfoList.MoveCurrentTo(SelectedDay.Date);
Comment est-ce que je peux faire ce travail? Je suis très nouveau à tout cela.
Avez-vous essayé de trouver l'objet ShootingDay dans le premier ShootingDayInfoList? puis utilisez l'objet trouvé pour remplacer ce paramètre 'SelectedDay.Date'. Vous pouvez essayer de le trouver en utilisant la boucle manuelle ou Linq – dnr3