xamarin.forms - What does x:Double mean for a Xamarin Button? -
my code has:
<button x:name="correctbutton" heightrequest="60" horizontaloptions="fillandexpand" verticaloptions="startandexpand"> <button.fontsize> <onplatform x:typearguments="x:double" ios="25" android="20" /> </button.fontsize> </button>
can explain x:double means
i have broken down comments in xaml.
<!-- here button declared, note how see x:name here --> <button x:name="correctbutton" heightrequest="60" horizontaloptions="fillandexpand" verticaloptions="startandexpand"> <!-- besides giving properties control, in case button, attributes, can set them adding them child nodes. happens fontsize here --> <button.fontsize> <!-- not setting fontsize here, letting value dependent on platform running on. ios value 25, android 20. --> <onplatform x:typearguments="x:double" ios="25" android="20" /> </button.fontsize> </button>
now, x:double
needed tell onplatform
tag type should provide it, can x:int32 or other type if needed. because provide string values in onplatform tag, needs know type has cast value.
remember pointed out x:name
property. x
shorthand namespace find type. if @ page declaration, have attribute like: xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
, see how x
declared here? why x
needed in front, tell xaml double
type can found in http://schemas.microsoft.com/winfx/2009/xaml
namespace, abbreviated x
default.
note onplatform
tag in way deprecated of xamarin.forms 2.3.4. should use such:
<button x:name="correctbutton" heightrequest="60" horizontaloptions="fillandexpand" verticaloptions="startandexpand"> <button.fontsize> <onplatform x:typearguments="x:double" x:key="windowbackgroundtable"> <on platform="android" value="20" /> <on platform="ios" value="25" /> </onplatform> </button.fontsize> </button>
Comments
Post a Comment