开发者

dynamically adding images to a list box in WPF

I have a WPF application that has a vertical listbox that I would like to programmaticly add images to. I want to be able to use a FileSystemWatcher to monitor the directory that the 开发者_如何转开发photos are in and when a new image is added or an image is deleted the list box will update the images in the application. Does anyone know how to accomplish this?


Very roughly, you bind the ItemsSource property of the ListBox to an ObservableCollection of images. Have your watcher process add images to the collection as they appear, and databinding should cause the ListBox to be updated as the backing collection changes.

Further: How to: Create and Bind to an ObservableCollection

That's the general concept. Can't get much more specific than that without knowing anything about your code. :) Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜