1
新的一頁
我從一個頁面傳遞幾個值到下一個。其中一個值位於子數組中。因爲可以有多個I想說如果計數大於一陣列內Artist
值,通過「羣星」,否則通過所述單個藝術家值。在這裏,我到目前爲止。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
我現在得到一個 「未分配使用局部變量_ra
的」 內for循環
現在,我不能訪問'name'。我碰到一個錯誤說 「'Artist2'不包含定義'name'」 – nos9
可以改變for循環爲:對於(INT I = 0;我<= selectedTrack.artists.Count-1;我++) –
確定現在我就在「未分配的局部變量的使用'內_rA'錯誤循環 – nos9