image - WPF application throws an 'XmlParseException was unhandled' when using Converter -


i building small wpf aplication learn myself wpf. , have encountered problem 1 of controlers. have object list of url's in string format, , want bind them image , use wpf converter class convert url's bitmaps.

but when implement converter program throws following error:

'xmlparseexception unhandled'

and in details says this:

"{"unable cast object of type 'changrabber.converter' type 'system.windows.data.ivalueconverter'."}"

this code referencing converter in xaml:

xmlns:local="clr-namespace:changrabber"> <window.resources>     <local:converter x:key="convert"/> </window.resources> 

this code use control:

<datatemplate>   <stackpanel orientation="horizontal">     <image source="{binding thumbimgurl, converter={staticresource convert}}" />   </stackpanel> </datatemplate> 

and here code converter:

namespace changrabber {     class converter     {         [valueconversion(typeof(string), typeof(bitmapimage))]         public class imageconverter : ivalueconverter         {             public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture)             {                 try                 {                     string mypath = (string)value;                     uri myuri = new uri(mypath);                     bitmapimage animage = new bitmapimage(myuri);                     return animage;                 }                 catch (exception)                 {                      return new bitmapimage(new uri("ikke funket"));                 }             }              public object convertback(object value, type targettype, object parameter, system.globalization.cultureinfo culture)             {                 throw new notimplementedexception();             }         } 

and is object binding image

class mainposts : mainlinks     {         public mainposts(string _title, string _link, string _posttext, string _imageurl, string _thumburl) :base(_title,_link)         {             posttext = _posttext;             imageurl = _imageurl;             thumbimgurl = _thumburl;         }          public string posttext { get; set; }          public string imageurl { get; set; }          public string thumbimgurl { get; set; }     } 

i have no idea why won't work, , getting abit frustrated on program. incredibly appreciated

use <local:imageconverter x:key="convert"/>


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -