WPF has this nice page with 11! rules for Value Precedence
Xamarin lacks this documentation, and apparently it differs from WPF.
What i've found so far:
(In WPF "Local Value" overrides almost everything else.)
Not so in Xamarin, where i identified this (partial) order:
VisualElement.Triggers
Style.Triggers
Local Value
Style Setter
So:
How's the complete Value precedence in Xamarin?
Related
I searched but could not find an up-to-date question, so here goes:
Could someone let me know what Xcodes Accessibility Label vs Hint vs Id are used for? I think it might be label and hint are used for voiced navigation and Id's are only used for automation, but not sure if that is right?
You are correct.
The 'Label' property will be used in voice over representing the element itself. If Labels are not set manually, they will be filled in at runtime based on the content of the element. IE: "Comment Delete Button"
'Hints' are also used in voice over assistance but are a more descriptive representation of the element. IE: "This button allows users to delete a comment."
'identifier' is used for automation and quick query of the UI element.
IE: "CommentDeleteButton"
The Label and Hint can be localized and therefore will vary between languages while the identifier remains the same.
https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/iPhoneAccessibility/Accessibility_on_iPhone/Accessibility_on_iPhone.html#//apple_ref/doc/uid/TP40008785-CH100-SW1
I'm pretty new to programming in Swift, and I'd like to know if there is an easy way to add settings/preferences to my Cocoa application in Swift. If possible, I'd like a step by step guide. I mostly want to know how you store the user's preferences on disk and the code part. In my current code it will need to check which setting the user has chosen, and based on that perform an action. I'm using Xcode 7.1 and Swift 2. Thanks in advance!
The NSUserDefaults class is very easy to use in code, and its shared instance is readily available for binding to controls in Interface Builder.
For example, if I wanted to have an integer preference named "elmer" and set its value to 7, it's as easy as:
NSUserDefaults.standardUserDefaults().setInteger(7, forKey: "elmer")
To read the value back:
let elmer: Int = NSUserDefaults.standardUserDefaults().integerForKey("elmer")
To bind the value to a control in Interface Builder, set the Controller Key to "values", and the preference name for the Model Key Path:
I would recommend reading the "Preferences and Settings Programming Guide", and also to familiar yourself with the "NSUserDefaults Class Reference".
SWITF 5.x
The class changed the name so now you do:
UserDefaults.standard.set("1234", forKey: "userID")
To set a key that can hold any type. Or you can be type specific like this
UserDefaults.standard.bool(forKey: "IsConfigured")
The UI binding still working in the same fashion #ElmerCat well explained.
I am building a UI in Interface Builder and am looking for the simplest (least code) way to identify an element from code.
I'd like to avoid using outlets because frankly I detest visual programming and don't want to pollute my class space with countless outlet properties. Is there some unique string identifier I can assign to static elements that I can either reference directly or easily look up from code?
Ideally I just want to look up an object by its id like I can do in JavaScript:
document.getElementById('myIdentifier');
I agree with rightfold that outlets are the best solution, but there is an answer that addresses your question directly: you can use the (integer) tag property of UIView (setting it either in IB or in code), and then you can fetch the view with the method UIView -viewWithTag:.
Successive calls to -viewWithTag: will iterate through the subviews that have the given tag. Because it's an integer, you'll probably want to use named constants for tag references in code, but unfortunately there's no way (that I am aware of) to use constants in that manner in IB.
The default value for the tag property is 0, so avoid using that as a semantically meaningful tag.
In my opinion, ListPicker list items are unacceptably small tap targets; certainly their height is smaller than the minimum size recommended by the style guide Microsoft published, and fact that Microsoft has taken to presenting the list full-screen in a much larger font suggests that I am not alone in holding this opinion.
I would like to use this full-screen big-font presentation in my own UI designs. I have tried specifying a DataTemplate (as a static resource) but it didn't seem to have any effect, although I'm pretty sure it is processed because when I made a typo in the resource name the compiler complained.
On what basis do you say that the item tap target size is too small? Is this personal opinion or based on user feedback?
If you don't like default style of the ListPicker then retemplate it.
You can use the ItemCountThreshold property to control whether FullMode is always used or not (set it to 0).
You can also apply a full mode template to increase the touoch target size of what is displayed there.
I was using ListPickerItem objects for the items. This works until there are enough items to trigger Full mode and then it barfs.
If I import the System namespace and use String objects, everything's hunky dory. Supplying a DataTemplate and binding to something also works.
I think I have found a bona fide bug, but one with a trivial workaround: don't use ListPickerItem.
Is it possible to determine which property of an ActiveX control is the default property? For example, what is the default property of the VB6 control CommandButton and how would I found out any other controls default!
/EDIT: Without having source to the object itself
I don't use VB, but here it goes.
I found Using the Value of a Control, but it's not a programmatic solution.
If you have access to the code, look for
Attribute Value.VB_UserMemId = 0
using Notepad.
It depends on when you want to determine this. You could print the "value" of, say, a label control (which has no "value" property) to the debugger like:
debug.print "Value for cmdTest is ["+format(cmdTest)+"]"
Which will give you something like:
Value for cmdTest is [False]
As it turns out, the default value for a command button is it's state (pressed or not), so if you put the code example above in the click event for the control, you will see "True", if you execute it somewhere else, you'll see "False".
For other results, this method will at least show you the sort of property you're looking for. You could use:
debug.print "cmdTest's value is of type ["+TypeName(oObject) +"]"
which tell you the actual type, namely:
cmdTest's value is of type [Boolean]
You could use various methods to narrow things down, such as setting the value and seeing what happens.
Use OLE/Com Object Viewer, which is distributed with Microsoft Visual Studio.
Go to type libraries and find the library the control is housed in, for example CommandButton is stored in Microsoft Forms 2.0 Object Library. Right click the library and select view. Find the coclass representing the control and select it:
As can be seen, the default interface for CommandButton is ICommandButton, when you inspect ICommandButton look for a property that has a dispid of 0. The IDL for the dispid 0 property of CommandButton is:
[id(00000000), propput, bindable, displaybind, hidden, helpcontext(0x001e8d04)]
void Value([in] VARIANT_BOOL rhs);
[id(00000000), propget, bindable, displaybind, hidden, helpcontext(0x001e8d04)]
VARIANT_BOOL Value();
Showing you the default property.
you have access to the code, look for
Unfortunetly I don't have access to the code for most of the controls. However the link is useful for the Microsoft Controls, but I still would like a way to know for other controls.