ವಿಂಡೋಸ್ ಅಂಗಡಿ ಅಪ್ಲಿಕೇಶನ್ ಫಾರ್ ಸರಣಿಬದ್ಧವಾಗಿ ಒಂದು 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:= ಹೆಸರಿಸಿ"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. ಇದು ತಾರ್ಕಿಕವಾಗಿ ಇದನ್ನು ಮಾಡಲು ಒಂದು ಸುಲಭ ಮಾರ್ಗ ಹುಡುಕಲು ಆಶ್ಚರ್ಯಕರವಾಗಿ ಹಾರ್ಡ್ ಮತ್ತು, 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ನನ್ನ ಬ್ಲಾಗ್ ಚಂದಾದಾರರಾಗಿ.

ನಲ್ಲಿ ಟ್ವಿಟ್ಟರ್ ನನ್ನನ್ನು ಅನುಸರಿಸಿ http://www.twitter.com/pagalvin

ಒಂದು ಉತ್ತರಿಸಿ ಬಿಡಿ

ನಿಮ್ಮ ಈಮೇಲ್ ವಿಳಾಸ ರ ಆಗುವುದಿಲ್ಲ. ಅಗತ್ಯವಿರುವ ಜಾಗ ಗುರುತಿಸಲಾಗಿದೆ *