Set ListItem foreground dynamically - windows-phone-7

I have an array that populates a ListBox in my app. At first I need to set the foreground of each listboxItem to gray, and that's easy enough through Binding the foreground color to the listboxItem.
The problem comes in where I then have to seperately (based other back end factors) set specific listboxItems foreground to black. The trick being to select a specific item on the already populated listbox and re-set the foreground without having to re-render the entire listbox.
The objects that I bind to the listbox each does have a guid/unique-id. So if I could just select the item on the listbox ('where id=1635135;?), and then set that items foreground to black..
It's quite difficult to explain this a bit more clearly, but if you have any questions please ask! Thanks!

If you implement the INotifyPropertyChanged in your ViewModel, just change the Foreground property to black for the items you want and they will automaticaly change from gray to black in your UI.

Related

How to mimic the item highlight behavior of NSTableView in NSCollectionView?

I have NSCollectionView with custom items which contain NSTextField and NSImageView.
I realized highlight behavior of collection view items manually (ie. redefined the setSelected: method in my NSCollectionViewItem descendant class).
I successfully change the background color of selected items, but I miss one small but important thing: the text color of the selected item doesn't change.
I know that the NSTableView item highlighting changes the text color along with the background color, but I cannot mimic it since I don't know the algorithm of color's change.
The text color of my NSCollectionViewItems can be different. When I highlight the item in NSTableView, the gray text becomes lightgray, black becomes white and so on.
Does anybody know how they do that? Maybe there's a ready solution in the Cocoa API that I missed? Please help.

How to change SwitchButton button's color

Where can i set color of the SwitchButton button? By default, it is white, so on the white background its looking wierd. I set all possible brushes to noteable color (blue), but button is still white.
Ideally, you probably want to just edit (or make a copy of) the original control template. Right click it, Edit Template->Edit and you can expose the objects in the template that make the background as well as the ones for the different states like MouseOver, IsChecked, etc and will allow you to do it directly to the object giving the current background. Which you often have to do if they dont have the Background property bound to the template you can specify with just Background="blah"
Which is what I would assume is the case since you have the background property set and it still doesn't show your change.
You could also expose that property in the template so from now on you could just specify Background="" by finding which object is that white background and changing its background property to;
Background="{TemplateBinding Background}"
Hope this helps.

How to change the background colour of a one particular listboxitem in a listbox in windows phone app?

i am developing an windows phone app.
I am having a listbox , in which depending upon on one particular condition i want to change only one listboxitem background colour .
Please Note :- i want to change background colour of only some listboxitems depending upon some particular condition.
Please let me know how i can achieve this ??
What are the various alternatives ??
Thanks in advance.
While you are binding the item sources to list box, add a property called background color and set this background color based on condition.
string background;
if(condition)
background="Red"; //Color you wish to set
List<ItemSet> source=new List<ItemSet>();
source.Add( new ItemSet(){ Background=background, OtherProperty=properties });
In the XAML you set the Background={Binding Background} for the list item.
If you have any issues let me know to it.

LongListSelector - Changing the colour of the current selected item

I have a weird situation.
I have a longlistselector with MVVM databinding. When one item get's selected, I change the colour of the text to the phone accent colour. But the item doesn't change its colour on the screen. ( even not when I scroll in the list )
If I then just switch to another page and come back, the item colour is changed if I scroll to it if it is not visible. If it is visible, it still hasn't changed colour until I scroll it out of view and back into view, then the colour will also change.
Anyone the same experience?
If you're changing a bound value but it's not being reflected in the UI then this will typically indicate that you're not correctly notifying of the change. Make sure you're implementing INotifyPropertyChanegd on the viewmodel and calling RaisePropertyChanged appropriately.

Background for Mac OS X app and other elements like NSButton, NSTabView

I changed the background color for my app, but other elements keep the same background color.
Looks like I missed some easy configuration, bsc for NSTabViewItems item colors is deprecated by docs, and using current theme...
You can't easily adjust the tint of the standard controls. You're going to have to subclass and override the drawing code for each of the elements.
Also, may I humbly suggest that you leave it the default color?
U may use Core Animation layer in IB. Choose your object (for example button),
open the view effects inspector (⎇⌘8), set checkbox with your object, add "content filters"
color monochrome and set color! That is all!

Resources