Description
When calling apply with a style, where the TargetType in the XAML style doesn't match the correct underlying control used by Titanium the error message is currently the below, it would be nice if we could catch the error correctly and then report this back to the user
[ERROR] ----- Titanium Javascript Runtime Error -----
[ERROR] In app.js: 6,12
[ERROR] Message: Uncaught Error: apply: unknown exception
var win = Ti.UI.createWindow({ backgroundColor: 'white' });
var lbl = Ti.UI.createLabel({
text: 'label'
})
var style = Ti.UI.Windows.createStyle({ source: 'ms-appx:///Styles.xaml' });
style.apply(lbl, 'LabelStyle');
win.open();
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="LabelStyle" TargetType="TextBox">
<Setter Property="Foreground" Value="Plum"></Setter>
</Style>
</ResourceDictionary>
Steps to reproduce
Copy the above app.js and styles.xaml into your project
Build for a Windows target
Actual
Unknown exception
error is thrown
Expected
A nicer error that maybe just spits back the error returned from nativeland?
WinRT information: Cannot apply a Style with TargetType 'Windows.UI.Xaml.Controls.TextBox' to an object of type 'Windows.UI.Xaml.Controls.TextBlock'.
No comments