C# 显示windows phone 8应用程序中作为源的图像名称从sqlite数据库获取的本地文件夹中的图像

C# 显示windows phone 8应用程序中作为源的图像名称从sqlite数据库获取的本地文件夹中的图像,c#,database,sqlite,windows-phone-8,C#,Database,Sqlite,Windows Phone 8,每个人实际上都在创建WindowsPhone8项目。我在隔离存储中有一个SQlite数据库文件,它有一个名为“teams”的表,表中的fied是id、teamu名称等 我已经插入了团队名称,如india、australia等,并且在我的应用程序本地文件夹中,我有一个团队图像,该名称存储在sqlite DB中,如india.png、australia.png等 在我的列表框中,我可以列出所有的团队名称和团队图像,这样我就可以编写 从sqlite DB检索数据并成功显示名称、id等 但是,问题是我想

每个人实际上都在创建WindowsPhone8项目。我在隔离存储中有一个SQlite数据库文件,它有一个名为“teams”的表,表中的fied是id、teamu名称等

我已经插入了团队名称,如india、australia等,并且在我的应用程序本地文件夹中,我有一个团队图像,该名称存储在sqlite DB中,如india.png、australia.png等

在我的列表框中,我可以列出所有的团队名称和团队图像,这样我就可以编写

从sqlite DB检索数据并成功显示名称、id等

但是,问题是我想显示本地文件夹中的图像,其中图像名称来自列为“country_name”的country表,因为

列名称和我的本地图像都有相同的名称

我的代码将比我认为的文本解释得更清楚:

我的XAML代码:

   <ListBox Name="scheduleListbox" Margin="5,85,5,60" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Height="100" Width="480" Margin="0,0,0,5" Background="CadetBlue">
                       <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Margin="3" Source="{Binding teamUrl}"></Image>
                        <TextBlock Grid.Column="1" Text="{Binding team1_Name}" Name="team1Name" Foreground="White"></TextBlock>                        
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
我的CS代码是这样的

  public partial class Schedule : PhoneApplicationPage
{      
    List<teams> teamsList;
    // the local folder DB path
    string DB_PATH = Path.Combine(ApplicationData.Current.LocalFolder.Path, "sample.sqlite");
    //SQLite connection
    private SQLiteConnection dbConn;

    dbConn = new SQLiteConnection(DB_PATH);

        /// Create the table Task, if it doesn't exist.
        dbConn.CreateTable<teams>();

       teamsList = dbConn.Query<teams>("select * from teams").ToList<teams>();

       // Bind source to listbox
       scheduleListbox.ItemsSource =teamsList;

    }

  public class teams
  {
    [PrimaryKey, AutoIncrement]
    public int id { get; set; }
    public string team_Name { get; set; }
  }
这里在类i中声明了与团队表列对应的数据成员,并且不能将团队名称指定为图像源

所以,有人请给我一个解决方案,将团队名称设置为图像的源,其中团队图像存储在本地文件夹中,路径为…/images/australia.png

我的要求:最后,我的要求是我想从SQLite DB中获取团队名称,并将此团队名称用作图像控件的源,以显示本地文件夹中的图像


提前感谢。

我发现自己满足了我的要求。我创建了另一个名为appendList的类,其中包含类团队中的所有现有数据成员和额外数据成员,如teamImage,如下所示

    public class teams
    {
      [PrimaryKey, AutoIncrement]
       public int id { get; set; }
      public string team_Name { get; set; }
    }
    public class appendList
     {
       [PrimaryKey, AutoIncrement]
       public int id { get; set; }
       public string team_Name { get; set; }
       public string teamImage
     }
并创建了这样的循环

      public partial class Schedule : PhoneApplicationPage
     {      
List<teams> teamsList;
 List<appendList> _appendList;
// the local folder DB path
string DB_PATH = Path.Combine(ApplicationData.Current.LocalFolder.Path, "sample.sqlite");
//SQLite connection
private SQLiteConnection dbConn;

dbConn = new SQLiteConnection(DB_PATH);

    /// Create the table Task, if it doesn't exist.
    dbConn.CreateTable<teams>();

   teamsList = dbConn.Query<teams>("select * from teams").ToList<teams>();
      //
      _appendList=new List<appendList>();
     foreach(var t in teamsList)
    {
      _appendList.add(new appendList
       {
          teamImage="/..your local image Path/"+t.team_name+".png";
       });
    }
   // Bind source to listbox
   scheduleListbox.ItemsSource =_appendList;

}
希望这能有所帮助