વિન્ડોઝ દુકાન એપ્લિકેશન માટે પ્રોગ્રામની એક ListBox માં ListboxItems ની ઊંચાઈ સુયોજિત કરી રહ્યા છે

I’m working on a windows store application and one of the things I want to do in the app is display a log that shows status messages and other informational tidbits as the user works things. આ માટે, હું ListBox નીચે પ્રમાણે ઉમેરી:

<ListBox X:= Name"GameStateLog" = HorizontalAlignment"કેન્દ્ર" ઊંચાઈ ="221" = VerticalAlignment"ટોચ" પહોળાઈ ="499" ગાદી ="0" = FontSize"10">

 

રનટાઈમે listbox રચના માટે C # કોડ લીટીઓ સાથે હતી:

GameStateLog.Items.Insert(0, GameStateCounter         + ": નવી રમત રાજ્ય: ખેલાડી માટે રાહ 1 નામ");

This worked out fine enough but the UI showed a crazy amount of padding around the individual messages as they were added. હું ઓવરને વપરાશકર્તાઓને આ વસ્તુઓ પસંદ કરવા માટે, પરંતુ હું માત્ર લોગ સંદેશાઓ ચાલતી શ્રેણી બતાવવા માંગો છો ત્યારે અર્થમાં બનાવવા નથી આપની સમક્ષ કરવા માંગો છો અર્થમાં બનાવે છે કે જે - વપરાશકર્તાઓને આ પસંદ નહીં, just view them. તે દલીલ આ કરવા માટે એક સરળ માર્ગ શોધી Strangely મુશ્કેલ હતું અને, the way I found it isn’t necessarily “easy” but I got it working OK. કી સમજ આ પોસ્ટ આવ્યાં અહીં (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c4a6f694-bd46-4779-ab83-b1c2fcb2397c) from Bob Relyea. તેના બદલે ListBox પર આઈટમ્સ સંગ્રહમાં શબ્દમાળાઓ ઉમેરવાનો, add ListBoxItems. શબ્દમાળા ઉમેરીને, the ListBox was creating its own ListBoxItem on its own. I wasn’t able to affect anything about that ListBoxItem after the fact. નવા કોડ છે:

        ખાનગી ગેરમાન્ય AddGameStateLogMessage(સ્ટ્રિંગ theMessage)
        {
            ListBoxItem કે = નવું ListBoxItem();
            li.Content = theMessage;
            li.MaxHeight = 25;

            જાડાઈ = thisPadding નવું જાડાઈ(5, 0, 5, 0);
            = thisPadding li.Padding;

            GameStateLog.Items.Insert(0,લિ);
        }

 

Here I’m creating ListBoxItem’s and inserting them. હું તેની જાડાઈ સેટ કરીને અધિક ગાદી દૂર.

હું સંદેશાઓ ચોક્કસ પ્રકારના પ્રકાશિત કરવા માટે કોડિંગ કેટલાક રંગ કરવું અને સીધી ListBoxItems ઉમેરીને હું શૈલી તેમને હું માંગો કોઈપણ રીતે મેળવવા માટે ઇરાદો નથી, આ ખૂબ સરળ છે.

આ કોઈને મદદ કરે છે આશા!

</અંત>

undefinedમારા બ્લોગ પર સબ્સ્ક્રાઇબ કરો.

Twitter પર મને ખાતે અનુસરો http://www.twitter.com/pagalvin

જવાબ છોડો

તમારું ઇમેઇલ સરનામું પ્રકાશિત કરવામાં આવશે નહીં. જરૂરી ક્ષેત્રો ચિહ્નિત થયેલ છે *