TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
R sowmya
NA
71
2.2k
my list-view doesn’t display images
Mar 6 2019 12:08 AM
my image converter class
public
sealed
class
ImageConverter : IValueConverter
{
public
BitmapImage ConvertByteArrayToBitMapImage(
byte
[] imageByteArray)
{
if
(imageByteArray ==
null
)
return
null
;
var byteBlob = imageByteArray
as
byte
[];
var ms =
new
MemoryStream(byteBlob);
var bmi =
new
BitmapImage();
bmi.StreamSource = ms;
return
bmi;
}
public
object
Convert(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
BitmapImage img =
new
BitmapImage();
if
(value !=
null
)
{
img =
this
.ConvertByteArrayToBitMapImage(value
as
byte
[]);
}
return
img;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
return
null
;
}
}
databinding logic
string
connection = ConfigurationManager.ConnectionStrings[
"POSconnection"
].ConnectionString;
SqlConnection con =
new
SqlConnection(connection);
SqlCommand cmd =
new
SqlCommand(
"SP_Getsubitem"
, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@getname"
,
"SALADS"
);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataTable dt =
new
DataTable();
DataSet ds =
new
DataSet();
da.Fill(dt);
getdatas.ItemsSource = dt.DefaultView;
mylistview code in xaml
<
ListView
x:Name
=
"getdatas"
ItemsSource
=
"{Binding}"
Margin
=
"-407,-270,47,120.2"
Grid.RowSpan
=
"2"
>
<
ListView.ItemContainerStyle
>
<
Style
TargetType
=
"ListViewItem"
>
<
Setter
Property
=
"BorderThickness"
Value
=
"5"
/>
<
Setter
Property
=
"Margin"
Value
=
"10"
/>
<
Setter
Property
=
"Padding"
Value
=
"10"
/>
</
Style
>
</
ListView.ItemContainerStyle
>
<
ListView.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding price}"
/>
<
Image
Height
=
"300"
Width
=
"300"
Source
="{Binding ImageFile,
Converter
={StaticResource ImageConverter}}"
/>
<
TextBlock
Text
=
"{Binding ImageFile}"
/>
</
StackPanel
>
</
DataTemplate
>
</
ListView.ItemTemplate
>
<
ListBox.ItemsPanel
>
<
ItemsPanelTemplate
>
<
UniformGrid
Columns
=
"5"
HorizontalAlignment
=
"Stretch"
/>
</
ItemsPanelTemplate
>
</
ListBox.ItemsPanel
>
</
ListView
>
Reply
Answers (
2
)
Explain real time use of delegates
iam using interop dll for word and facing one problem