How to change SwitchButton button's color - windows-phone-7

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.

Related

How to display elements inside NSCollectionView with various shapes

I am a rookie Cocoa guy. I need to design and implement a view which will show collection of labels on Mac OS using Xamarin. These labels will have a text and color associated with them. When shown inside the view, label should expand till it covers whole text and it will be shown with background and foreground colors.
I have attached the picture of this user control on Windows, you can see that labels inside the StackPanel are expanding till they cover the whole text. Hope this gives better idea about my ask.
The $64,000 question is "are these labels controls?" In other words, do you expect the user to click on these to do something, or are they just for display?
If your answer is "just for display", the solution is super simple: Use an NSTextField and programmatically add attributed text (NSAttributedString) to it. Attributed text attaches display properties to runs of text within the field; properties like "background color".
If you want these to be buttons that you can click on, then things get a lot more complicated.
Since you apparently want the button layout to "flow", you might look into imbedding buttons (well, button cells) into an NSTextField using attachments. This is normally how non-text content (say, an image) can be inserted, but with some fiddling it can actually be anything a control cell can draw. See How to insert a NSButton into a NSTextView? (inline).
Warning: this is not a "rookie" topic and will involve control cells and custom event handling.
If I were doing this, I'd probably just create NSButton objects for each label (choosing an appropriate style/look like NSRecessedBezelStyle), create a custom subclass of NSView to contain them, and then override the layout method to position all of the buttons the way I want.
To be thorough, I'd also override the intrinsic size methods so the whole thing could participate in auto-layout, based on the number and size of buttons it contained.

How do I set NSColorWell mode?

I have an NSColorWell to allow the user to change the color of the text.
If I set the default to black, the NSColorPanel which appears seems a little useless to beginners, as the color wheel only shows solid black (which is normal). So I want to set the mode to, perhaps, Crayons. I can't figure out how to do this though - the color panel appears by default when my NSColorWell is clicked - how do I talk to it or intercept it to set the mode?
I needed to obtain a reference to the sharedColorPanel. To change the mode, I send the setMode message with a constant from the color panel modes enum to the sharedColorPanel.
NSColorPanel *cpanel = [NSColorPanel sharedColorPanel];
[cpanel setMode:NSCCrayonModeColorPanel]; // [cpanel setMode:7];
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSColorPanel_Class/Reference/Reference.html

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!

NSLevelIndicator with text on It?

How can I add text on top of a NSLevelIndicator? [the NSLevelIndicator is in my statusbar, if that matters]
The best way to add text to your NSLevelIndicator user interface is by adding a separate Label NSTextField. The NSLevelIndicator control does not have a title or other text associated with it.
From within Interface Builder, just grab a Label and drag it to your window above or beside the NSLevelIndicator.
Contrary to the correct answer to your previous question, if you want to use an NSLevelIndicator as a background and draw text on top of it, you're better off creating a custom view that owns and uses an NSLevelIndicatorCell for the background drawing.
You might also consider drawing the background yourself; e.g., fill with your choice of green/yellow/red, and then draw a white gradient on top of it. This is more appropriate if you're not really indicating a level with your level indicator.
Also, don't forget to test your application with Sim Daltonism, to make sure that the text is still readable to color-blind users.

How can I change the way NSButtonCell objects highlight when clicked?

I am using several NSButtonCell objects in an NSTableView. They are simple square buttons with custom images on them.
These buttons draw properly when they are not highlighted: all that is visible is the image, and the rest of the button rectangle is transparent. However, when I click on them, the entire button rectangle is highlighted, inverting the background in the parts that were transparent.
I would prefer to see the image drawn inverted, and the transparent parts remain transparent. How can this be done?
Try setting your cell's highlightsBy property to NSContentsCellMask. I think you'll have to do this in code (probably in awakeFromNib); I don't see a way to do it in IB alone.
You can do it in Interface Builder too. I use "Square Button" so the button alters between two images (so the image is not inverted at all).
Your buttons behaviour is probably set to "Momentary Light" or "Momentary Push In".
Set the Behaviour to "Momentary Change", and it should work.

Resources