1
私はあるページからいくつかの値を渡しています。値の1つはサブ配列内にあります。配列内に複数のArtist
値がある可能性があるので、カウントが1より大きい場合は、 "Various Artists"を渡し、そうでなければ単一アーティスト値を渡します。ここで私はこれまで何を持っているのですか?ここでWP7はサブ配列から新しいページに値を渡します
は私のクラスには、選択した項目からデータをプルする
public class RootObject
{
//public MetadataRelease metadata { get; set; }
public Results results = new Results();
public IEnumerator<Results> GetEnumerator()
{
return this.results.GetEnumerator();
}
}
public class Results
{
public Release release { get; set; }
public List<Track> tracks { get; set; }
//public List<UsersAlsoBought2> usersAlsoBought { get; set; }
//public List<LatestFromLabel2> latestFromLabel { get; set; }
internal IEnumerator<Results> GetEnumerator()
{
throw new NotImplementedException();
}
}
public class Track
{
public int id { get; set; }
public bool selected { get; set; }
public string type { get; set; }
public string name { get; set; }
public bool active { get; set; }
public string mixName { get; set; }
public string title { get; set; }
public string slug { get; set; }
public string isrc { get; set; }
public string releaseDate { get; set; }
public string publishDate { get; set; }
public string sampleUrl { get; set; }
public string rtmpStreamUrl { get; set; }
public bool exclusive { get; set; }
public Price2 price { get; set; }
public AudioFormatFee2 audioFormatFee { get; set; }
public string currentStatus { get; set; }
public string length { get; set; }
public int bpm { get; set; }
public Key key { get; set; }
public string saleType { get; set; }
public List<Artist2> artists { get; set; }
public List<Genre2> genres { get; set; }
public List<object> subGenres { get; set; }
public List<object> charts { get; set; }
public Release2 release { get; set; }
public Label2 label { get; set; }
public Images2 images { get; set; }
public DynamicImages2 dynamicImages { get; set; }
}
public class Artist2
{
public int id { get; set; }
public string name { get; set; }
public string slug { get; set; }
public string type { get; set; }
}
コードです。
public void musicSampleSelectedHandler(object sender, RoutedEventArgs e)
{
Track selectedTrack = (sender as Image).DataContext as Track;
ListBoxItem pressedItem = this.listReleaseMain.ItemContainerGenerator.ContainerFromItem(selectedTrack) as ListBoxItem;
if (pressedItem != null)
{
string _rN = selectedTrack.release.name;
string _rT = selectedTrack.title;
string _rS = selectedTrack.sampleUrl;
string _rI = selectedTrack.images.large.url;
string _rA;
if (selectedTrack.artists.Count > 1)
{
_rA = "Various Artists";
}
else
{
for (int i = 0; i <= selectedTrack.artists.Count - 1; i++)
_rA += "," + selectedTrack.artists[i].name;
}
this.NavigationService.Navigate(new Uri("/Pages/MediaPage.xaml?releaseUrl=" + _rS + "&releaseTrack=" + _rT + "&releaseImg=" + _rI + "&releaseName=" + _rN + "&releaseArtist=" + _rA, UriKind.Relative));
}
}
UPDATE
私は今あなたが "IF/ELSE" 文の中_rAを宣言しているので、これはforループ
。 "Artist2"に 'name'の定義が含まれていないと言うエラーが出る – nos9
forループを次のように変更できますか?for(int i = 0; i <= selectedTrack.artists.Count-1; i ++) –
Ok今私は "forループの中で未使用のローカル変数' _rA'エラーを使用しています – nos9