Hi,
I’m upgrading my project from 0.12.4 to 0.20.2 and have followed the upgrade guide. However one last error remains when I try to preview my project:
Configuring (5.61s)
Compiling syntax tree
C:\Users\fernandolins\OneDrive\Documentos\GitHub\TowardPrototipo\build\Local\Preview\cache\TowardDemo.unoproj.g.uno(806.66): E2047: No implicit cast from 'MainView' to Uno.UX.PropertyObject
(0.95s)
Build completed in 6.57 seconds.
0 Warning(s)
1 Error(s)
# Build complete.
I’m really not sure what the error is about. I am using the same .unoproj
format as specified in the upgrade guide:
{
"Packages": [
"Fuse",
"FuseJS",
"Fuse.BasicTheme"
],
"Includes": [
"*"
]
}
Hi, I’v got the same problem on my project after upgrading from 0.12.4 to 0.20.2
Hi guys,
This is strange, but it sounds like you are databinding to properties on the App tag itself, which won’t work in the current version.
If that’s not the case, can you please provide a test project?
Hi Anders,
Here is my project so you can debug it: https://dl.dropboxusercontent.com/u/2273140/fernandolins86_prototype.zip
It is quite extensive and far from the best code you’ll see because it’s pretty much a collection of UI behaviors. As you will see the <App>
tag has no databinding in it.
By the way my code uses this replacement for Styles; I’m not sure if it could be the cause: https://www.fusetools.com/community/forums/howto_discussions/resources_in_their_own_file_replacement_for_style?page=1
Thanks!
Hi!
The problem is that TabSinc.ux
refers to this.Background
which implies the backgorund color of the App
itself. Properties on App
can not be used in bindings, unfortunately. Instead of using App.Background
, consider using a root panel with a background.
Hello,
I added a Background to the ClientPanel
inside of <App>
, and also tried adding a new Panel
with the Backgroud property inside the ClientPanel
, but the error still appears.
I checked the documents where I used this.SomeProperty
but they all have parent nodes; shouldn’t they be getting the property from their parents? The this.Background
you mentioned above is inside a TWButton
which is a Panel
that already contains a background defined in ElementosUI.ux
.
Hi Anders,
After a little more digging I am now getting errors related to the keys set on the ResourceContainer class (and the previous error is gone):
C:\Users\user\Documents\GitHub\TowardPrototipo\TowardPrototipo\ElementosUI.ux(135): E8001: 'this' declared in Cores.ux(1) is a member 'CoresInclude' and cannot be accessed from 'TWButton'. To make this work, consider making 'TWButton' an ux:InnerClass of 'CoresInclude'.
C:\Users\user\Documents\GitHub\TowardPrototipo\TowardPrototipo\ElementosUI.ux(135): E8001: 'this' does not contain property 'TextLabel'
TowardDemo: E0000: Object reference not set to an instance of an object.
This is the code block:
<Panel ux:Class="TWButton" HitTestMode="LocalVisualAndChildren" Background="{Resource branco}" FontSize="14" TextColor="{Resource azul00}" TextAlignment="Center" Padding="12" Margin="0,6,0,6" Focus.IsFocusable="true" ux:Name="_thisTWBInstance">
<float4 ux:Property="Background" />
<float4 ux:Property="TextColor" />
<string ux:Property="TextLabel" />
<TextAlignment ux:Property="TextAlignment" />
<float ux:Property="FontSize" />
<!-- LINE 135 BELOW -->
<Text Value="{Property this.TextLabel}" TextColor="{Property this.TextColor}" TextAlignment="{Property this.TextAlignment}" Alignment="Center" FontSize="{Property this.FontSize}" ux:Name="_thisText" Margin="0" Padding="0"/>
<Rectangle CornerRadius="4" Layer="Background">
<SolidColor Color="{Property this.Background}" ux:Name="_thisBackground"/>
<Stroke Color="{Property this.TextColor}" Width="1" ux:Name="_thisStroke"/>
</Rectangle>
<WhileFocused>
<Change Target="_thisStroke.Width" Value="2"/>
</WhileFocused>
<WhilePressed>
<Change Target="_thisStroke.Color" Value="{Property this.Background}" Duration="0" DurationBack="0.3" Easing="CubicOut"/>
<Change Target="_thisBackground.Color" Value="{Property this.TextColor}" Duration="0" DurationBack="0.3" Easing="CubicOut"/>
<Change Target="_thisText.TextColor" Value="{Resource branco}" Duration="0" DurationBack="0.3" Easing="CubicOut"/>
</WhilePressed>
</Panel>
This is Cores.ux basically:
<ResourceContainer ux:Class="CoresInclude">
<float4 ux:Value="#0D1C2F" ux:Key="azul03" />
<float4 ux:Value="#1A385D" ux:Key="azul02" />
<float4 ux:Value="#26548B" ux:Key="azul01" />
<!-- other floats listed ... -->
<float4 ux:Value="#FFFFFF" ux:Key="branco" />
<float4 ux:Value="#000000" ux:Key="preto" />
</ResourceContainer>
Resolution
As of 0.20, you can only use this
to refer to a parent element that has a ux:Class
. If it is not found, it will look up the parent nodes for an ux:Class
and if none is found, it will eventually reach the App
tag which cannot have its properties targeted.
So this behavior which was accepted in 0.12.x has now changed and will cause this problem.
To fix it, give your element an ux:Name
and use that to access its properties (e.g. this.Background
==> myElementsUxName.Background
) instead of the now deprecated behavior of this
.
THank you @duckers!