This is a migrated thread and some comments may be shown as answers.

Databind Image in TileVIew

1 Answer 87 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Rick Mueller
Top achievements
Rank 1
Rick Mueller asked on 27 Aug 2010, 04:38 PM
Using the  XmlDataProvider I'm able to bind all the data to the correct elements. Works great in the MainWindow Xaml.  When I Put the TileView control in a page xaml using the same XmlDataProvider I'am able to bind all the elements except the image. I tried using a Imageconverter, but no luck. Is there a trick to get this to bind or I'm missing something?

Any thoughts?

Regards,
Rick

xmlns:local="clr-namespace:Digital_Kitchen_CdrPrint"
<local:ImageConverter x:Key="ImageConverter" />

<Image x:Name="listImg" Source="{Binding XPath=EmpImage, Converter={StaticResource ImageConverter}}"  Stretch="Uniform"/>

 

 

public class ImageConverter : IValueConverter

 

{

 

 

public object Convert(object value, Type targetType, object parameter,

 

CultureInfo culture)

{

String xml =

 

"<Tables>" + "<Table>" + ((XmlElement)value).InnerXml.ToString() + "</Table>" + "</Tables>";

 

XmlDocument XDoc =

 

new XmlDocument();

 

XDoc.LoadXml(xml);

 

 

// XmlNodeList oXmlNode = XDoc.GetElementsByTagName("Station");

 

 

 

//XmlNode node = XDoc.SelectSingleNode("RecipeName");

 

 

XmlNode oXnode = XDoc.SelectSingleNode(

 

"Tables/Table/EmpImage");

 

value = oXnode.LastChild.Value;

BitmapImage image =

 

new BitmapImage();

 

 

 

if (value != null)

 

{

 

 

try

 

{

image.BeginInit();

image.CacheOption = BitmapCacheOption.OnLoad;

image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;

image.UriSource =

 

new Uri((string)value, UriKind.Absolute);

 

image.EndInit();

}

 

 

catch

 

{

image =

 

null;

 

}

}

 

 

return image;

 

}

 

 

public object ConvertBack(object value, Type targetType, object parameter,

 

CultureInfo culture)

{

 

 

throw new Exception("The method or operation is not implemented.");

 

}

}

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 01 Sep 2010, 02:03 PM
Hi Rick,

Where are the images stored? Do you see any exceptions being thrown in the Output window? If the images are part of the wpf project, what is their Build Action? I've attached a sample project with which I try to mimic your scenario. Have a look at it and let me know if it helps. If you can send me a sample project demonstrating the issue, I'd be better able to assist you.

All the best,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TileView
Asked by
Rick Mueller
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or