[TIMOB-19516] Windows: Support setting Content property of ContentControl subclasses with a simple string content
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-09-28T09:42:55.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.1.0 |
| Components | Windows |
| Labels | n/a |
| Reporter | Christopher Williams |
| Assignee | Christopher Williams |
| Created | 2015-09-14T23:08:06.000+0000 |
| Updated | 2015-11-03T22:21:41.000+0000 |
Description
If you're using native API access and create something like a Windows.UI.Xaml.Controls.Button, you'd naturally want to set a text label for the button. But the Content property is a Platform.Object with the understanding it could be a String or it could be an UIElement (in fact it could be a UIElement, and if it's not then it's basically converted to a String representation, though how that's done isn't really talked about).
We need to understand this nuance of the API and support settings string values easily, i.e.
button.Content = "Click me!";
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.contentcontrol.content
Verified using: Windows 10 Pro Appc Core: 5.1.0-42 Appc NPM: 4.2.1 Ti SDK: 5.1.0.v2015102819002 When using the code below the app loads fine and the strings are set for both the button and textblock
Closing ticketvar Window = require('Windows.UI.Xaml.Window'), TextBlock = require('Windows.UI.Xaml.Controls.TextBlock'), Button = require('Windows.UI.Xaml.Controls.Button'), Canvas = require('Windows.UI.Xaml.Controls.Canvas'), window = Window.Current, canvas = new Canvas(), text = new TextBlock(), button = new Button(); text.Text = "Text1"; text.FontSize = 12; button.Content = "Button text"; canvas.Children.Append(button); canvas.Children.Append(text); Canvas.SetLeft(button, 70); Canvas.SetTop(button, 140); Canvas.SetTop(text, 250); Canvas.SetLeft(text, 70); window.Content = canvas; window.Activate();