This project is read-only.

Having a little trouble getting going with ListBox

Jul 1, 2010 at 9:04 AM
Edited Jul 1, 2010 at 9:05 AM

Hi Tom.


Having a spot of bother adjusting to the new beta.

In my app, the first screen that comes up after a fresh install is one that presents a list of languages for the user to choose.

I've declared my item as such:


public LangItem(string title)
            : base()
            this.Font = new FontSprite(GlFontFamily.GenericSansSerif, 12, FontStyle.Bold, true);
            this.Text = title;
            Height = 80;
On my screen, I'm then setting up my listbox in the constructor with:
view = new ListBox();
            view.Margin = new Margin(3, 3, 3, 3);
            view.TapItem += (s, e) => SetLanguage(e.Item as LangItem);

            //Create new item
            LangItem smi;
            //create header
            smi = new LangItem("Select Language");
            smi.Enabled = false;

            //create languages available.
            foreach(String lang in Languages)
                smi = new LangItem(lang.Replace(".xml", ""));
                smi.Enabled = true;


        void view_TapItem(object sender, ItemEventArgs e)
            SetLanguage(e.Item as LangItem);
This all works - my screen displays "Select language" along with an item for each one. 
But when I tap the item, nothing happens - the call to SetLanguage never occurs.
I can't quite figure out where I am going wrong; and in fact once it seemed to work after 
I tapped *lots*. Also, the debugging seems fond of locking up the process on the device now.
If I click "stop" in VS to end the debug session, the app running on the device doesn't kill off, and I have to do a soft reset? Any pointers?


Jul 1, 2010 at 9:47 AM

EDIT - OK, think its alright now. I still had an override in an underlying screen to focus a listview which I commented out and it seems ok... Looks like that was confusing it somehow.

Next task is to create a new Item that can have an icon and subtext and so on...  but I coudn't see a "Controls" property to add them to. Will check the demo code to see if I can work it out.