リストボックスにバインディング テキストが表示されているのに、バインディング イメージが表示されないという問題があります。私はxmlファイルをダウンロードして解析し、必要なテキストを表示しますが、ステータスに応じて画像を表示したいと考えています。Linename
OKをService
表示しますが、バインディング イメージはまったく表示されません。Atype は、GetImage メソッドを呼び出すために使用されるだけです (よくわかりません)。次に、ステータスに従って ImageSource を設定する必要がありますが、画像はまったく表示されません。
XElement XmlTweet = XElement.Parse(e.Result);
var ns = XmlTweet.GetDefaultNamespace();
listBox1.ItemsSource = from tweet in XmlTweet.Descendants(ns + "LineStatus")
select new FlickrData
{
Linename = tweet.Element(ns + "Line").Attribute("Name").Value,
Service = tweet.Element(ns + "Status").Attribute("Description").Value,
Atype = GetImage(tweet.Element(ns + "Status").Attribute("Description").Value)
};
public String GetImage(String type)
{
FlickrData f = new FlickrData();
switch(type)
{
case "Good Service":
f.Type = new BitmapImage(new Uri("/Images/status_good.png", UriKind.Relative));
break;
case "Minor Delays":
f.Type = new BitmapImage(new Uri("/Images/status_minor.png", UriKind.Relative));
break;
case "Severe Delays":
f.Type = new BitmapImage(new Uri("/Images/status_severe.png", UriKind.Relative));
break;
case "Planned Closure":
f.Type = new BitmapImage(new Uri("/Images/status_minor.png", UriKind.Relative));
break;
}
return "anything";
}
FlickrData では、画像ソースType
が表示されない単純な get set です。
public class FlickrData
{
public string Linename { get; set; }
public string Service { get; set; }
public string Detail { get; set; }
public ImageSource Type { get; set; }
public string Atype { get; set; }
}