views:

30

answers:

2

I have a combobox (ItemsSource="{Binding Path=AvailableDrives}").

The AvailableDrives property is defined like this:

 public List<DriveInfo> AvailableDrives
    {
        get
        {
            return DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.Removable).ToList();
        }
    }

It works OK, but i would like that if i plug in/out a USB device that the comboBox gets repopulated without having to close and reopen the window.

How can i achieve this?

thanx#

+1  A: 

Simple method will be to put a timer on your form and query for the drives when its event fires. Then update combo box with new values.

TheVillageIdiot
thanx for the advice. I will try this aproach also.
no9
well i kinda used this solution. Used System.Threading.Timer and handled the selected when it gets updated. It works.
no9
+3  A: 

There's a good example of how to do this on codeproject: Detecting USB Drive Removal in a C# Program

Prise
i belive this is the correct solution, yet i managed to do what i wanted using timer. Still thumbs up.
no9