Windows phone 7 循环选择器中显示的WP7项目

Windows phone 7 循环选择器中显示的WP7项目,windows-phone-7,Windows Phone 7,我使用loopingselector可视化标志,这些标志以经典方式加载到列表中,如图所示: public MainPage() { InitializeComponent(); List<DataContinent> data = new List<DataContinent>(); data.Add(new DataContinent() { Flag = new Uri("/Images/Albania.png", UriKind.Rela

我使用loopingselector可视化标志,这些标志以经典方式加载到列表中,如图所示:

public MainPage()
{
    InitializeComponent();

    List<DataContinent> data = new List<DataContinent>(); 
    data.Add(new DataContinent() { Flag = new Uri("/Images/Albania.png", UriKind.Relative).ToString() });
    data.Add(new DataContinent() { Flag = new Uri("/Images/Andorra.png", UriKind.Relative).ToString() });
    ...
    ...
    this.loopingSelectorContinent.DataSource = new ListLoopingDataSource<DataContinent>() {Items = data, SelectedItem = data[0]};
}
public主页()
{
初始化组件();
列表数据=新列表();
Add(newdatacontraction(){Flag=newURI(“/Images/albana.png”,UriKind.Relative).ToString()});
Add(newDataContinental(){Flag=newURI(“/Images/andorr.png”,UriKind.Relative).ToString()});
...
...
this.loopingSelectorContant.DataSource=new ListLoopingDataSource(){Items=data,SelectedItem=data[0]};
}

是否可以在运行时根据所选的洲在loopingselector中加载不同的图像,或者作为替代方案,防止某些项目的循环?

我找到了一种简单的方法来解决我将要描述的问题,因为它可能对其他人有用。 基本上,不必在Main中初始化loopingselector,它可以在Main外部完成,然后在必要时调用适当的函数。 这里有一个例子:

public MainPage()
{
    InitializeComponent();
    Europe(); //standard visualization
}

public void Europe()
{
    List<DataContinent> data = new List<DataContinent>(); 
    data.Add(new DataContinent() { Flag = new Uri("/Images/Albania.png", UriKind.Relative).ToString() });
    data.Add(new DataContinent() { Flag = new Uri("/Images/Andorra.png", UriKind.Relative).ToString() });
    ...
    ...
    this.loopingSelectorContinent.DataSource = new ListLoopingDataSource<DataContinent>() {Items = data, SelectedItem = data[0]};
}
public void Africa()
{
    List<DataContinent> data = new List<DataContinent>(); 
    data.Add(new DataContinent() { Flag = new Uri("/Images/Algeria.png", UriKind.Relative).ToString() });
    data.Add(new DataContinent() { Flag = new Uri("/Images/Angola.png", UriKind.Relative).ToString() });
    ...
    ...
    this.loopingSelectorContinent.DataSource = new ListLoopingDataSource<DataContinent>() {Items = data, SelectedItem = data[0]};
}

private void button1_Click(object sender, RoutedEventArgs e) //loopingselector populated with European flags
{
Europe();
}

private void button2_Click(object sender, RoutedEventArgs e) //loopingselector populated with African flags
{
Africa();
}
public主页()
{
初始化组件();
Europe();//标准可视化
}
公共空间(欧洲)
{
列表数据=新列表();
Add(newdatacontraction(){Flag=newURI(“/Images/albana.png”,UriKind.Relative).ToString()});
Add(newDataContinental(){Flag=newURI(“/Images/andorr.png”,UriKind.Relative).ToString()});
...
...
this.loopingSelectorContant.DataSource=new ListLoopingDataSource(){Items=data,SelectedItem=data[0]};
}
公共空间(非洲)
{
列表数据=新列表();
Add(newdatacontraction(){Flag=newuri(“/Images/alegaria.png”,UriKind.Relative).ToString()});
Add(newdatacontraction(){Flag=newURI(“/Images/Angola.png”,UriKind.Relative).ToString());
...
...
this.loopingSelectorContant.DataSource=new ListLoopingDataSource(){Items=data,SelectedItem=data[0]};
}
private void button1\u Click(对象发送方,RoutedEventArgs e)//使用欧洲标志填充的loopingselector
{
欧洲();
}
私有无效按钮2\u单击(对象发送方,RoutedEventArgs e)//循环选择器填充非洲标志
{
非洲();
}