The TextView component can be used to type larger text content in your app. The component can also be used show any content by setting the editable property to false.
<StackLayoutid="stackLayoutId"><Buttontext="Disable third TextView"tap="{{ onTap }}"/></StackLayout>
functiononNavigatingTo(args){const page = args.object;const vm =newobservableModule.Observable();// changing TextView editable property value on button tap
vm.set("onTap",(btargs)=>{const button = btargs.object;const thirdTextview = btargs.object.page.getViewById("thirdTextViewId");
thirdTextview.editable=!thirdTextview.editable;if(thirdTextview.editable){
button.text="Disable third TextView";}else{
button.text="Enable third TextView";}});
page.bindingContext= vm;}functiononPageLoaded(args){const page = args.object;const vm = page.bindingContext;const stackLayout = page.getViewById("stackLayoutId");// creating new TextView and changing the hintconst firstTextview =newtextViewModule.TextView();
firstTextview.hint="Enter text";// creating new TextView and binding the text propertyconst secondTextview =newtextViewModule.TextView();const options ={
sourceProperty:"text",
targetProperty:"secondTextProperty"};
secondTextview.bind(options, vm);
vm.set("secondTextProperty","Sample TextView text");// creating new TextView and changing the textconst thirdTextview =newtextViewModule.TextView();
thirdTextview.id="thirdTextViewId";
thirdTextview.text="Third TextView";// adding the newly created TextViews in a StackLayout
stackLayout.addChild(firstTextview);
stackLayout.addChild(secondTextview);
stackLayout.addChild(thirdTextview);}
exports.onNavigatingTo= onNavigatingTo;
exports.onPageLoaded= onPageLoaded;
exportfunctiononNavigatingTo(args){const page: Page =<Page> args.object;const vm =newObservable();// changing TextView editable property value on button tap
vm.set("onTap",(btargs)=>{const button: Button =<Button> btargs.object;const thirdTextview =(<TextView>button.page.getViewById("thirdTextViewId"));
thirdTextview.editable =!thirdTextview.editable;if(thirdTextview.editable){
button.text ="Disable third TextView";}else{
button.text ="Enable third TextView";}});
page.bindingContext = vm;}exportfunctiononPageLoaded(args){const page: Page =<Page> args.object;const vm = page.bindingContext;const stackLayout: StackLayout =<StackLayout> page.getViewById("stackLayoutId");// creating new TextView and changing the hintconst firstTextview =newTextView();
firstTextview.hint ="Enter text";// creating new TextView and binding the text propertyconst secondTextview =newTextView();const options ={
sourceProperty:"text",
targetProperty:"secondTextProperty"};secondTextview.bind(options, vm);
vm.set("secondTextProperty","Sample TextView text");// creating new TextView and changing the textconst thirdTextview =newTextView();
thirdTextview.id ="thirdTextViewId";
thirdTextview.text ="Third TextView";// adding the newly created TextViews in a StackLayout
stackLayout.addChild(firstTextview);
stackLayout.addChild(secondTextview);
stackLayout.addChild(thirdTextview);}