Cartlanna míosúla: Bealtaine 2013

Tapaidh agus éasca: Socraigh an Méid na Míreanna i mBosca Liosta i Store App Windows

I App Store Windows Tá mé ag cruthú, Ba mhaith liom a thaispeáint don úsáideoir teachtaireachtaí eolais éagsúla.  Phioc mé listbox mar an uirlis a thaispeáint dó ionas gur féidir leo a scrollú trí iad agus go léir go stuif maith. 

Is iad na teachtaireachtaí eolais amháin, so there’s no need to provide all that extra whitespace around them since the user can never select them for anything.  The default behavior of the ListBox provides a substantial amount of padding and I wanted to get rid of it.  Well …. you can’t do that sort of thing on the ListBox directly.  HOWEVER, you can do it to the items you add:

        príobháideach neamhní AddGameStateLogMessage(teaghrán theMessage)
        {
            TextBox t = nua TextBox();
            t.Text = GameStateCounter   + ": " + theMessage;
            t.TextWrapping = TextWrapping.Wrap;
            t.MinWidth = 400;
            Tiús thisPadding = nua Tiús(5, 0, 5, 0);
            t.Padding = thisPadding;
            t.FontSize = 12;

            ListBoxItem go = nua ListBoxItem();
            li.Content = t;
            li.MaxHeight = 25;
            thisPadding = nua Tiús(5, 0, 5, 0);
            li.Padding = thisPadding;

            GameStateLog.Items.Insert(0,li);
        }

in the above, I’m creating a TextBox and setting its font, its padding, etc.

Ar Aghaidh, I create a ListBoxItem and set its content to the formatted TextBox.

Mar fhocal scoir, I insert the ListBoxItem into the ListBox.  (I want to show most recent messages at the top of the list, hence the Insert(0,li) instead of a simple Add() invocation.).

I will be tweaking this a bit before I’m really happy with the ListBox behavior but the pattern shown above has been very fruitful.  Hopefully someone else finds it helpful.

</deireadh>

undefinedLiostáil le mo bhlag.

Lean mé ar Twitter ag http://www.twitter.com/pagalvin