I am new to developing Windows phones and Silverlight. During my teachings, I encountered an error that I mentioned in the title of this post.
My main goal is to save and extract the image file to the SQLCE database, and I used this tutorial http://antonswanevelder.com/2011/10/28/writing-an-image-to-sql-ce-linq-to-sql /
However, I had a problem with this piece of code
<Image Source="{Binding ItemImage, Converter={StaticResource ImageConverter}}" Stretch="UniformToFill"/>
My idea is that the compiler cannot find the resulting ImageConverter. I really need help with this.
My code: MainPage.xaml
<phone:PhoneApplicationPage.Resources> <DataTemplate x:Key="CallListListBoxItemTemplate"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding CallName}" Foreground="DarkCyan" FontSize="{StaticResource PhoneFontSizeLarge}" VerticalAlignment="Top" Margin="12,12,0,0"/> </StackPanel> </DataTemplate> <DataTemplate x:Key="PersonalInfoListBoxItemTemplate"> <Grid > <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Image Source="{Binding PersonImage, Converter={StaticResource ImageConverters}}" Stretch="UniformToFill" Name="_personPhoto" />
MainPage.xaml.cs
public class ImageConverters : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is byte[]) { MemoryStream ms = new MemoryStream(value as byte[]); WriteableBitmap wb = PictureDecoder.DecodeJpeg(ms, 100, 100); return wb; } else { return null; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }
source share