This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi I'm looking for a way to change the Foreground property (or maybe the Opacity) of the text content of a loopinglistboxitem in code, depending on some user action. I've tried various approaches:
but none of these work. In a previous project where I had a standard templated list box, I created a BoolToVisibility Converter that willhide or show an element based on the bool value of a source object. Although I'm sure I could use the same approach here, I was wondering if there wasn't some way I could identify the selected textblock of the loopinglistboxitem in code and make changes to the appearance there at run time. Can this be done? |
|
|
Hello I have added 2 new properties to the LoopingListBox control which you may find useful. These properties will be in the next nightly build (available from about 1200GMT). Nightly builds can be downloaded from http://www.mindscapehq.com/products/phone-elements/nightly-builds (trial editions) or http://www.mindscapehq.com/store/myaccount (full editions). One of the new properties is called SelectedLoopingListBoxItem. You can listen to the selection changed event, and in the event handler, get the selected LoopingListBoxItem using this property. From this, you can hack the visual tree to find the TextBlock hosted within it which you can modify at run time as you like. The other property is called ItemContainerStyle. This provides a XAML solution to your problem which I would recommend you use rather than using the SelectedLoopingListBoxItem solution. With this property you can specify the style used by the LoopingListBoxItems. You can create a custom style which allows you to change the foreground when the item is selected. Here is some example XAML of a LoopingListBoxItem style that changes the foreground of the content to HotPink in the selection state. You could use this to set the ItemContainerStyle property.
See which of these 2 solutions works best for you and let us know if you need more help. -Jason |
|
|
That's superb! Thanks, Jason. I'm sure one of them will do the trick for me. |
|