Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
Closed
Changes from 1 commit
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
27d6e21
Update documentation to version 0.3.0
ErjanGavalji Oct 17, 2014
11636d8
Merge branch 'ErjanGavalji/v0.3.0'
ErjanGavalji Oct 17, 2014
00757b1
Apply newly generated API reference
ErjanGavalji Nov 19, 2014
99c0468
Sort the TOC
ErjanGavalji Nov 19, 2014
8f473e4
Merge branch 'ErjanGavalji/v0.4.0' into release
ErjanGavalji Nov 19, 2014
58547b8
Move Api reference to a folder of its own
ErjanGavalji Nov 19, 2014
6d8e772
Add content topics
ErjanGavalji Nov 19, 2014
d8a5794
Merge branch 'ErjanGavalji/move-api-reference-to-specific-folder' int…
ErjanGavalji Nov 19, 2014
337d31d
Merge branch 'release'
ErjanGavalji Nov 20, 2014
823540c
Fix ApiReference link
ErjanGavalji Dec 3, 2014
b28dd72
Add 0.4.2 articles
ErjanGavalji Dec 15, 2014
59ade14
Some fixes on content and auto-generated files
ErjanGavalji Dec 15, 2014
50854d9
Create ui-with-xml.md
Dec 17, 2014
e7185aa
Update ui-with-xml.md
Dec 17, 2014
567ed61
Update ui-with-xml.md
Dec 17, 2014
f2a7fc3
Update ui-with-xml.md
Dec 17, 2014
10d2b39
Update README.md
Dec 17, 2014
6dfbf45
Update README.md
Dec 17, 2014
c1df805
Update ui-with-xml.md
Dec 17, 2014
8fb2eaa
Add positions
ErjanGavalji Dec 18, 2014
8e21982
Create ui-with-xml.md
Dec 17, 2014
61ace61
Update ui-with-xml.md
Dec 17, 2014
fab7ed1
Update ui-with-xml.md
Dec 17, 2014
d5a5fd3
Update ui-with-xml.md
Dec 17, 2014
b6e945d
Update README.md
Dec 17, 2014
6a8b962
Update README.md
Dec 17, 2014
d3fd486
Update ui-with-xml.md
Dec 17, 2014
6d06edf
Improve nav titles
ErjanGavalji Dec 18, 2014
98d773a
Reorder pages
ErjanGavalji Dec 18, 2014
72cb082
Fix titles and nav-titles
ErjanGavalji Dec 18, 2014
25244ce
Update the navigation article
ErjanGavalji Dec 18, 2014
2dc8884
Update ui-with-xml.md
Dec 18, 2014
252f98b
Update ui-with-xml.md
Dec 18, 2014
9690c2c
Update ui-with-xml.md
Dec 18, 2014
bc2f857
Update ui-with-xml.md
Dec 18, 2014
90fdad3
Update ui-with-xml.md
Dec 18, 2014
c92b664
Update ui-with-xml.md
Dec 18, 2014
d44cd72
Update ui-with-xml.md
Dec 18, 2014
01f9351
Update ui-with-xml.md
Dec 18, 2014
dff99f5
Merge branch 'ErjanGavalji/v0.4.2' into release
ErjanGavalji Dec 18, 2014
b71da48
Fix merge conflict
ErjanGavalji Dec 18, 2014
5140f29
Added Navigation article.
hamorphis Jan 8, 2015
29cdfa7
UI views articles
Jan 12, 2015
0cf020b
Update ui-views.md
Jan 12, 2015
0b3f3e2
Added location module overview.
Jan 13, 2015
1ad345c
Fixed some wording and typos.
Jan 13, 2015
2158c71
Merge pull request #11 from NativeScript/nnikolov/LocationDocs
Jan 13, 2015
724d0ef
Updated the navigation article.
hamorphis Jan 13, 2015
b6109a7
Merge pull request #12 from NativeScript/navigation
hamorphis Jan 13, 2015
83c972c
Update ui-views.md
Jan 13, 2015
9982dab
Updated navigation article.
hamorphis Jan 13, 2015
102e2c0
Merge pull request #13 from NativeScript/navigation
hamorphis Jan 13, 2015
ff6555f
Create ui-dialogs
Jan 13, 2015
b13dce7
Rename ui-dialogs to ui-dialogs.md
Jan 13, 2015
76715d0
Update ui-dialogs.md
Jan 13, 2015
5c435cd
Update ui-dialogs.md
Jan 13, 2015
e7437aa
Update ui-dialogs.md
Jan 13, 2015
e416876
Update ui-dialogs.md
Jan 13, 2015
6b150be
Update ui-dialogs.md
Jan 13, 2015
b52a317
Update ui-dialogs.md
Jan 13, 2015
f7dd544
Update ui-dialogs.md
Jan 13, 2015
86beebb
Added application-management help file.
hamorphis Jan 14, 2015
9fabd08
Merge pull request #14 from NativeScript/application-management
hamorphis Jan 14, 2015
2c1b674
Update README.md
Jan 14, 2015
7ba0514
Update ui-dialogs.md
Jan 14, 2015
93ad2e9
Fixed a typo.
hamorphis Jan 14, 2015
ffd6520
Update ui-with-xml.md
Jan 14, 2015
b6da85f
Update ui-with-xml.md
Jan 14, 2015
9a71efc
Update ui-with-xml.md
Jan 14, 2015
23f0906
Update ui-with-xml.md
Jan 14, 2015
5fb887f
Update ui-with-xml.md
Jan 14, 2015
a96cd0f
Update ui-with-xml.md
Jan 14, 2015
0541f7d
Update ui-with-xml.md
Jan 14, 2015
47faa0d
Update ui-with-xml.md
Jan 14, 2015
8bb01a7
Update ui-with-xml.md
Jan 14, 2015
d601df6
Fixed the ordering.
hamorphis Jan 14, 2015
bbcba42
Update ui-with-xml.md
Jan 14, 2015
c19ab28
Merge pull request #15 from NativeScript/fix
hamorphis Jan 14, 2015
ad8d526
Update ui-with-xml.md
Jan 14, 2015
3f92a1e
Update ui-with-xml.md
Jan 14, 2015
1244a55
Refactored data binding documentation.
Jan 14, 2015
de021e3
Merge pull request #16 from NativeScript/nnikolov/DataBindingDocs
Jan 14, 2015
497d2e0
Escape curly brackets from ui-with-xml.md
ErjanGavalji Jan 14, 2015
66fe2ea
Escape the curly brackets from the bindings.md as well
ErjanGavalji Jan 14, 2015
eebcd53
Fixing a couple small typos
tjvantoll Dec 23, 2014
b1716c6
Improved some parts of documentation.
Jan 14, 2015
72c9480
Merge pull request #19 from NativeScript/nnikolov/DataBindingDocs2
Jan 14, 2015
6233934
Added the stub for the modules article.
hamorphis Jan 15, 2015
5dc5b0f
Merge pull request #20 from NativeScript/modules
hamorphis Jan 15, 2015
852a585
Adding documentation about events.
Jan 19, 2015
bdf4157
Update bindings.md
ErjanGavalji Jan 19, 2015
c67bf4b
Update bindings.md
ErjanGavalji Jan 19, 2015
76ebe0e
Some typo fixes
ErjanGavalji Jan 19, 2015
0c6182f
Merge pull request #21 from NativeScript/nnikolov/EventsDocumentation
Jan 19, 2015
9514be3
modules help topic.
hamorphis Jan 21, 2015
b14dc97
Merge pull request #22 from NativeScript/modules
hamorphis Jan 21, 2015
6863a09
Rebuilt the help against the latest sources.
hamorphis Jan 23, 2015
4b98141
Merge pull request #23 from NativeScript/modules
hamorphis Jan 23, 2015
d22e59b
Fix encoding issues
ErjanGavalji Jan 23, 2015
6b6691c
Regenerate modules
ErjanGavalji Jan 23, 2015
919242f
Dependency property documentation.
Jan 24, 2015
881eb60
Minor edits to content
ErjanGavalji Jan 24, 2015
7f12c99
Merge pull request #24 from NativeScript/nnikolov/PropertiesDoc
Jan 24, 2015
2eab93a
Added links to color and fps-meter HOW-TOs
hamorphis Jan 23, 2015
535aee5
Added observable module HOW-TO.
hamorphis Jan 23, 2015
2fef220
Added several HOW-TOs
hamorphis Jan 26, 2015
99b7474
Merge pull request #25 from NativeScript/howtos
hamorphis Jan 26, 2015
a42134b
Regenerate the docs
ErjanGavalji Jan 26, 2015
95a1372
Screenshots
Jan 27, 2015
b667de6
Merge pull request #26 from NativeScript/feature/screenshots
Jan 27, 2015
261e199
Added frame HOW-TO
hamorphis Jan 26, 2015
16b789a
Added gestures HOW-TO.
hamorphis Jan 26, 2015
1eab011
Added search-bar HOW-TO.
hamorphis Jan 27, 2015
5cf8dfa
Added image-cache HOW-TO.
hamorphis Jan 27, 2015
b2f670a
Added dialogs HOW-TO.
hamorphis Jan 27, 2015
abb2191
Merge pull request #27 from NativeScript/howtos
hamorphis Jan 27, 2015
dd4104e
Update bindings.md
Feb 3, 2015
4432a43
Fix image paths
ErjanGavalji Feb 4, 2015
afaf5cc
Getting started with the "Getting Started" article
Jan 13, 2015
8a336b8
Add headers
Jan 14, 2015
d19d964
More on getting-started article
Feb 4, 2015
8b18e97
Added jsdocs for all public modules.
hamorphis Feb 5, 2015
f1ca932
Merge pull request #29 from NativeScript/modules-api-ref
hamorphis Feb 5, 2015
6e2bf53
Added documentation for gestures.
hamorphis Feb 5, 2015
e51dca8
Fixed spacing.
hamorphis Feb 5, 2015
38b3420
fix
hamorphis Feb 5, 2015
fe8268e
Merge pull request #30 from NativeScript/gestures
hamorphis Feb 5, 2015
5697eb2
Merge pull request #28 from NativeScript/feature/getting-started
Feb 5, 2015
f0c20c7
Added Style properties.
Feb 9, 2015
1a76906
Merge pull request #31 from NativeScript/nnikolov/StylePropertiesHelp
Feb 9, 2015
53274b4
Update getting-started.md
Feb 9, 2015
2973f88
Replaced BCL with NativeScript.
Feb 9, 2015
40488b7
Merge pull request #32 from NativeScript/nnikolov/HelpRemainngTasks
Feb 9, 2015
deddc72
Styling link removed
Feb 9, 2015
2811114
Max width and height removed
Feb 9, 2015
5d7aeaa
Updated gestures doc + API ref.
hamorphis Feb 9, 2015
e6aac89
New version of Api Reference.
Feb 10, 2015
3e572c0
Merge pull request #33 from NativeScript/nnikolov/HelpRemainngTasks
Feb 10, 2015
fd73f43
Updated the api-ref
hamorphis Feb 10, 2015
ab618da
Merge pull request #35 from NativeScript/api-ref
hamorphis Feb 10, 2015
858060a
Use an index.md as main page. Use a README.md link to it to visualize…
ErjanGavalji Feb 10, 2015
3f7cd70
Delete the README. Test if Github will handle
ErjanGavalji Feb 10, 2015
3dbebad
Revert "Delete the README. Test if Github will handle"
ErjanGavalji Feb 10, 2015
97dad07
Merge branch 'ErjanGavalji/ensure-index-html'
ErjanGavalji Feb 10, 2015
f3f500e
Add links to android and ios docs
Feb 10, 2015
c7b1733
Update Api reference to latest.
Feb 10, 2015
3593f2b
Merge pull request #37 from NativeScript/nnikolov/HelpRemainingTasks2
Feb 10, 2015
f307a05
Updated Api reference to the latest state.
Feb 11, 2015
49c7fff
Merge pull request #38 from NativeScript/nnikolov/HelpRemainingTasks3
Feb 11, 2015
592dbc2
A few trivial spelling fixes
tjvantoll Feb 11, 2015
7137139
Updated Api reference with latest and greatest.
Feb 12, 2015
3433696
Update for Api reference to latest.
Feb 12, 2015
6465652
Added Borders HOW-TO.
hamorphis Feb 13, 2015
797bfac
Refreshed the API Reference
ErjanGavalji Feb 13, 2015
31be347
Sligthly reordered topics.
Feb 13, 2015
a4a7264
Merge pull request #41 from NativeScript/nnikolov/TopicsReorder
Feb 13, 2015
a0df685
Update Api ref to latest and greatest.
Feb 13, 2015
efb3be1
Merge pull request #42 from NativeScript/nnikolov/ApiRefUpdate
Feb 13, 2015
91d8061
Get the content
ErjanGavalji Feb 13, 2015
0f33911
Add the jekyll header
ErjanGavalji Feb 13, 2015
8e34cb7
Help-ify the doc
ErjanGavalji Feb 13, 2015
5fc5b51
Change the reference to the CLI article
ErjanGavalji Feb 13, 2015
f225e75
Merge branch 'ErjanGavalji/cli-article'
ErjanGavalji Feb 13, 2015
9da10fa
Update API Reference
ErjanGavalji Feb 13, 2015
20c29d4
Update Api ref w/ fixed interface labels
ErjanGavalji Feb 13, 2015
a648dc4
Lollipop gallery app screenshots
Feb 13, 2015
12c8b78
Merge pull request #44 from NativeScript/feature/lollipop-screens
Feb 16, 2015
9e00694
Add .gitattributes file to have win line endings fixed
ErjanGavalji Feb 16, 2015
42c4981
layouts updated
Feb 19, 2015
acba7d3
layouts updated
Feb 19, 2015
d1b6aad
layouts updated
Feb 19, 2015
547795c
layouts updated
Feb 19, 2015
b5fb30e
layouts updated
Feb 19, 2015
43c3176
layouts updated
Feb 19, 2015
ee4cb55
Update Api Reference
ErjanGavalji Feb 20, 2015
f1547b2
Regenerate Api Ref
ErjanGavalji Feb 20, 2015
7a3c678
Rename all "panel"s to "layout"s
ErjanGavalji Feb 20, 2015
a57001d
Regenerate Api Reference
ErjanGavalji Feb 20, 2015
8192ad1
Styling topic updated with adding css options.
Feb 20, 2015
08b9889
ApiReference latest and greatest.
Feb 20, 2015
72cda16
Merge pull request #45 from NativeScript/nnikolov/StylingDocUpdate
Feb 20, 2015
8df0aa4
Add the runtime-specific submodules
ErjanGavalji Feb 20, 2015
9ec92d9
Update the homepage to point to the platform-specific topics
ErjanGavalji Feb 20, 2015
71c248d
Merge branch 'ErjanGavalji/add-runtime-specific-docs'
ErjanGavalji Feb 20, 2015
a5898d8
Corrupted line endings
ikoevska Feb 23, 2015
76a25c0
Edited Application Management
ikoevska Feb 23, 2015
35f53ee
Fix the mainModule description
ErjanGavalji Feb 24, 2015
5d3081f
Edited the navigation article
ikoevska Feb 24, 2015
5f65d7d
Update styling.md
Feb 24, 2015
b5853c4
Merge pull request #47 from NativeScript/app-wide-css-fix
Feb 24, 2015
59e6679
Rename images and add dock-layout image
Feb 24, 2015
2ca8f62
Dock image updated
Feb 24, 2015
a83a829
Merge pull request #48 from NativeScript/feature/rename-images
Feb 24, 2015
84067fa
Update ApiRef
ErjanGavalji Feb 24, 2015
83d3f31
ImagePage images updated
Feb 24, 2015
6e7225f
Reworking the overview
ikoevska Feb 24, 2015
c43b897
Corrupted line endings
ikoevska Feb 24, 2015
1cadf18
Layouts article
Feb 25, 2015
ce2e804
Edited Application Management
ikoevska Feb 23, 2015
94d20ec
Edited the navigation article
ikoevska Feb 24, 2015
c00f54e
Reworking the overview
ikoevska Feb 24, 2015
1a5ec6b
Merge branch 'ikoevska/beta-release' of https://github.com/NativeScri…
ikoevska Feb 25, 2015
9aa659f
Reworked layouts
ikoevska Feb 25, 2015
9e21211
Setup guides
ikoevska Feb 27, 2015
bcdf80b
Tweaked the homepage to list the platforms for which you can develop.
ikoevska Feb 28, 2015
2b7eb27
Tweaked the ab setup articles
ikoevska Feb 28, 2015
f1237d7
Hello World with AppBuilder
ikoevska Feb 28, 2015
98b153c
Reworked modules
ikoevska Feb 28, 2015
cde34ef
Proofreading the UI with XML docs.
ikoevska Mar 2, 2015
3405711
Fixed navigation in the article
ikoevska Mar 2, 2015
c486b43
Hello World with the NativeScript CLI
ikoevska Mar 2, 2015
d5a589f
Regenerate the API reference
ErjanGavalji Mar 2, 2015
54b552c
Proofreading ui-views.md
ikoevska Mar 2, 2015
a5896a4
Proofreading dialogs
ikoevska Mar 2, 2015
f1c0263
Recreating Getting Started and moving the overview part to it.
ikoevska Mar 3, 2015
8c5fcae
Merge pull request #51 from NativeScript/ikoevska/beta-release
ikoevska Mar 3, 2015
8e51d8d
Fix header
ErjanGavalji Mar 3, 2015
8af7370
Fix build
ErjanGavalji Mar 3, 2015
6c29f6f
Fixing titles and a few broken links to images
ikoevska Mar 3, 2015
80c6a2f
Moving hello world and setup to top level as the nesting no longer ma…
ikoevska Mar 3, 2015
f863dc6
Reworked titling, fixed image references
ikoevska Mar 3, 2015
d54d920
Fixing titling and ordering for the rest of the docs, grouping in the…
ikoevska Mar 3, 2015
b1d09c3
Updated getting started article for the CLI
tjvantoll Mar 3, 2015
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Style properties.
  • Loading branch information
Nedyalko Nikolov committed Feb 9, 2015
commit f0c20c7e6e9c55a85a6772b800cf56cb2d8b31ee
229 changes: 227 additions & 2 deletions properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ function validateMyProperty(value) {
}
return false;
}
exports.myPropertyProperty = new dependencyObservable.Property("myProperty", "MyClass", new dependencyObservable.PropertyMetadata("", dependencyObservable.PropertyMetadataOptions.None, null, validateMyProperty));
exports.myPropertyProperty = new dependencyObservable.Property("myProperty", "MyClass",
new dependencyObservable.PropertyMetadata("",
dependencyObservable.PropertyMetadataOptions.None, null, validateMyProperty));
var MyClass = (function (_super) {
...
```
Expand Down Expand Up @@ -210,7 +212,9 @@ export var myPropertyProperty = new dependencyObservable.Property(

``` JavaScript
var dependencyObservable = require("ui/core/dependency-observable");
exports.myPropertyProperty = new dependencyObservable.Property("myProperty", "MyClass", new dependencyObservable.PropertyMetadata("", dependencyObservable.PropertyMetadataOptions.Inheritable));
exports.myPropertyProperty = new dependencyObservable.Property("myProperty", "MyClass",
new dependencyObservable.PropertyMetadata("",
dependencyObservable.PropertyMetadataOptions.Inheritable));
var MyClass = (function (_super) {
__extends(MyClass, _super);
function MyClass() {
Expand Down Expand Up @@ -252,3 +256,224 @@ export class MyClass extends dependencyObservable.DependencyObservable {
```

> Creating an inheritable property is relatively simple (as seen in the previous example). However keep in mind that the **inheritance** magic only happens through the **visual tree**. Thus, setting such a property to a non visual element will not work as expected.

#Style properties

Maybe the best use case of inheritable properties is applying different styles and themes. The task is limited to setting a property (theme or style) of the most base container and every single UI component will inherit it via visual tree.

##Setting a style property

Setting style properties is no different than setting a regular property, just use the nested **style** object (within View class which means that every UI component has style).

* Via code

``` JavaScript
var color = require("color");
someButton.style.backgroundColor = new color.Color("red");
```
``` TypeScript
import color = require("color");
someButton.style.backgroundColor = new color.Color("red");
```

* Via css

``` JavaScript
someButton.id = "someButton";
someButton.css = "#someButtton {background-color: red}";
```
``` TypeScript
someButton.id = "someButton";
someButton.css = "#someButtton {background-color: red}";
```

##Creating a custom style property

Even that setting a custom value to a style property is not a big deal, creating a custom style property is a little bit more complicated. The process of creation of a custom style property contains several easy steps.

* Declaring a custom style property

``` JavaScript
var styleProperty = require("ui/styling/style-property");
var depObservable = require("ui/core/dependency-observable");

exports.fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family",
new depObservable.PropertyMetadata(undefined, depObservable.PropertyMetadataOptions.AffectsMeasure),
null);
```
``` TypeScript
import styleProperty = require("ui/styling/style-property");
import depObservable = require("ui/core/dependency-observable");

export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family",
new depObservable.PropertyMetadata(undefined, depObservable.PropertyMetadataOptions.AffectsMeasure),
null);
```

Careful reader will notice that style properties are special kind of properties. In fact **styleProperty.Property** class inherits from **depObservable.Property** class and adds the option for setting this property via css (second parameter in constructor). Second step is to register hadler (StylePropertyChangedHandler) object which will take care about synchronization of the property value with the underlying native object. In order to create such handler we should provide methods for **setting**, **resetting** and **getting the native**. First method will be used to set a value to the native object, reset method will be used to restore the default value of the native object and this default value is taken by the third method. For convinience this code could be wrapped in a class called **Styler**. NativeScript provides interface (for now only for better readability) called **Styler**. This interface has only one method to implement **registerHandlers** - here handlers for all properties defined in this Styler should be registered.

* Register a handler for the custom property

``` JavaScript
var styles = require("ui/styling");

var MyTextViewStyler = (function () {
function MyTextViewStyler() {
}
MyTextViewStyler.setFontFamilyProperty = function (view, newValue) {
if (view.android) {
view.android.setTypeface(android.graphics.Typeface.create(newValue,
android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = view._nativeView.titleLabel.font.pointSize;
view._nativeView.titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
}
};
MyTextViewStyler.resetFontFamilyProperty = function (view, nativeValue) {
if (view.android) {
view.android.setTypeface(android.graphics.Typeface.create(nativeValue,
android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = view._nativeView.titleLabel.font.pointSize;
view._nativeView.titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);
;
}
};
MyTextViewStyler.registerHandlers = function () {
styles.stylers.registerHandler(exports.fontFamilyProperty,
new styles.stylers.StylePropertyChangedHandler(MyTextViewStyler.setFontFamilyProperty,
MyTextViewStyler.resetFontFamilyProperty, MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
};
MyTextViewStyler.getNativeFontFamilyValue = function (view) {
if (view.android) {
return view.android.getTypeface();
}
else if (view.ios) {
return view._nativeView.titleLabel.font.fontName;
}
return null;
};
return MyTextViewStyler;
})();
exports.MyTextViewStyler = MyTextViewStyler;
```
``` TypeScript
import styles = require("ui/styling");

export class MyTextViewStyler implements styles.stylers.Styler {
public static setFontFamilyProperty(view: view.View, newValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue,
android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
}
}

public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue,
android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
}
}

public static getNativeFontFamilyValue = function (view: view.View): any {
if (view.android) {
return (<android.widget.TextView>view.android).getTypeface();
}
else if (view.ios) {
return (<UIButton>view._nativeView).titleLabel.font.fontName;
}
return null;
}

public static registerHandlers() {
styles.stylers.registerHandler(fontFamilyProperty, new styles.stylers.StylePropertyChangedHandler(
MyTextViewStyler.setFontFamilyProperty,
MyTextViewStyler.resetFontFamilyProperty,
MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
}
}
```

The important part of this class is the call to the static method **styles.stylers.registerHandler** which registeres **styles.stylers.StylePropertyChangedHandler** with a property. The third optional parameter indicates which class should react on a change of the new property value (in fact every inheritor class will react on changes).

* Using the new custom property

``` JavaScript
var stackPanelDef = require("ui/panels/stack-panel");
var buttonModule = require("ui/button");
var pages = require("ui/page");

var MyButton = (function (_super) {
__extends(MyButton, _super);
function MyButton() {
_super.apply(this, arguments);
}
return MyButton;
})(buttonModule.Button);
exports.MyButton = MyButton;
MyTextViewStyler.registerHandlers();
function createPage() {
var panel = new stackPanelDef.StackPanel();
var btn = new MyButton();
btn.text = "The quick brown fox jumps over the lazy dog.";
btn.id = "btn";
var btn1 = new MyButton();
btn1.text = "The quick brown fox jumps over the lazy dog.";
btn1.id = "btn1";
var btn2 = new buttonModule.Button();
btn2.text = "The quick brown fox jumps over the lazy dog.";
panel.addChild(btn);
panel.addChild(btn1);
panel.addChild(btn2);
var page = new pages.Page();
page.css = "#btn {font-family: Courier New} #btn1 {font-family: Times New Roman} #btn2 {color: yellow}";
page.content = panel;
return page;
}
exports.createPage = createPage;
```
``` TypeScript
import stackPanelDef = require("ui/panels/stack-panel");
import buttonModule = require("ui/button");
import pages = require("ui/page");

export class MyButton extends buttonModule.Button {

}

MyTextViewStyler.registerHandlers();

export function createPage() {
var panel = new stackPanelDef.StackPanel();

var btn = new MyButton();
btn.text = "The quick brown fox jumps over the lazy dog.";
btn.id = "btn";

var btn1 = new MyButton();
btn1.text = "The quick brown fox jumps over the lazy dog.";
btn1.id = "btn1";

var btn2 = new buttonModule.Button();
btn2.text = "The quick brown fox jumps over the lazy dog.";

panel.addChild(btn);
panel.addChild(btn1);
panel.addChild(btn2);

var page = new pages.Page();
page.css = "#btn {font-family: Courier New} #btn1 {font-family: Times New Roman} #btn2 {color: yellow}";
page.content = panel;
return page;
}
```