Images not displaying in listview local folder Windows Phone App

时间:2015-05-24 21:58:53

标签: c# image listview windows-phone-8 data-binding

I am trying to show an image within a list view that is in a folder called flags but I'm pulling the data from parse.com in the form of \flags\flagname.png. But it's not displaying the flag my question is how do I achieve this.

<ListView x:Name="history" ItemsSource="{Binding}">
    <ListView.Resources>
        <DataTemplate x:Key="myCell">
            <StackPanel>
                <TextBlock x:Name="name" HorizontalAlignment="Left"  TextWrapping="Wrap" Text="{Binding name, Mode=OneTime}" VerticalAlignment="Top" Style="{StaticResource TitleTextBlockStyle}" />                        
                <Image  Width="100" Height="100" Source="{Binding image, Mode=OneTime}"/> 
            </StackPanel>
        </DataTemplate>
    </ListView.Resources>
    <ListView.ItemTemplate>
        <StaticResource ResourceKey="myCell"/>
    </ListView.ItemTemplate>
</ListView>    

My WorldClocks class is as follows:

public class WorldClocks
{
    public string id { get; set; }
    public string name { get; set; }
    public string image { get; set; }

    public static async Task<WorldClocks> CreateFromParseObject(ParseObject parseObject)
    {
        return await Task.Run<WorldClocks>(() =>
        {
            var clocks = new WorldClocks();

            clocks.id =  parseObject.ObjectId;
            if (parseObject.ContainsKey("name"))
            {
                clocks.name = (string)parseObject["name"];
            }

            if (parseObject.ContainsKey("image"))
            {
                clocks.image = (string)parseObject["image"];
            }
            return clocks;
        });
    }
}

This is my context:

public class WorldClockDataContext
{
    public async Task<List<WorldClocks>> LoadAllClocks()
    {
        var query = ParseObject.GetQuery("clocks");
        IEnumerable<ParseObject> result = new List<ParseObject>();
        try
        {
            result = await query.FindAsync();
        }
        catch (Exception ex) {}

        var clocksItems = new List<WorldClocks>();
        foreach (var clocksItemParseObject in result)
        {
            var newsItem = await WorldClocks.CreateFromParseObject(clocksItemParseObject);
            clocksItems.Add(newsItem);  
        }
        return clocksItems;
    }
}

1 个答案:

答案 0 :(得分:0)

对不起家伙我的错误它正在工作我忘了包括构建动作=内容然而图像规模是错误的看起来blury任何建议