R
R
rad952019-08-27 18:31:38
WPF
rad95, 2019-08-27 18:31:38

Why are the images not showing up in the ListBox?

I'm trying to display file icons, but they are displayed in the wrong format.

Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(path);
Image icon = ico.ToBitmap();
lstBox.Items.Add(icon);

5d654cd70eff7106275989.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cyber_roach, 2019-08-27
@rad95

Because in the template of the ListBoxItem list element, there is a TextBlock,
which, of course, cannot draw bitmaps.
Just create your own data template for the list item.
Well, as it were, the very first request to Google gives a dozen solutions:
https://stackoverflow.com/questions/2081900/wpf-ad...
https://ru.stackoverflow.com/questions/487722/Image...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question