我是新手,正在学习Windows手机和银光开发。在我的练习中,我遇到了一个错误,就是本帖标题中提到的问题。
我的主要目标是将图像文件保存和检索到SQLCE数据库中,并使用以下教程:http://antonswanevelder.com/2011/10/28/writing-an-image-to-sql-ce-linq-to-sql/ 然而,我在这段代码中遇到了问题: 我的想法是编译器无法找到资源ImageConverter。我真的需要帮助。我的代码是:MainPage.xaml
我的主要目标是将图像文件保存和检索到SQLCE数据库中,并使用以下教程:http://antonswanevelder.com/2011/10/28/writing-an-image-to-sql-ce-linq-to-sql/ 然而,我在这段代码中遇到了问题: 我的想法是编译器无法找到资源ImageConverter。我真的需要帮助。我的代码是: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();
}
}