You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UserControl code-behind constructor is not called #61
I have found a issue in the {Binding} system on android.
I created a example under link
The problem is the following.
Usercontrol1 is a parent of Usercontrol2
Usercontrol1 has the Datacontext not set from code behind. (Datacontext == null)
Usercontrol2 has the Datacontext set from code behind.
Binding for sub-controls in Usercontrol2 doesn't work
WORKAROUND:
Setting the Datacontext of Usercontrol1 in code behind makes the bindings in Usercontrol2 to work
Workaround (2020-01-20)
Add the following property to all the project heads, in the first <PropertyGroup>:
Currently, the constructor of a user controls is not called directly, but rather calls a secondary constructors that allows for skipping the first level of a UserControl Xaml file. This choice was arbitrarily made when Android 4.4 was still in full swing, because the stack size on those android version for the main looper is very small (<32K).
This Xaml user control interpretation relaxation allowed for richer UIs for those older Android versions, because there were less UI elements in the visual tree, and that we tend not to use code behind as well.
To fix
Add a feature flag that disables this behavior, while keeping the call to OnInitializeCompleted for backward compatibility.
Activity
jeromelaban commentedon Jun 26, 2018
This issue is actually not a binding issue, but rather a
UserControlspecific feature, for which the constructor is not called on purpose.I'll update the issue to reflect the actual problem.
Workaround
In Level1.xaml.cs, name the first
StackPanelasroot, then do this instead:Details
Currently, the constructor of a user controls is not called directly, but rather calls a secondary constructors that allows for skipping the first level of a
UserControlXaml file. This choice was arbitrarily made when Android 4.4 was still in full swing, because the stack size on those android version for the main looper is very small (<32K).This Xaml user control interpretation relaxation allowed for richer UIs for those older Android versions, because there were less UI elements in the visual tree, and that we tend not to use code behind as well.
To fix
Add a feature flag that disables this behavior, while keeping the call to
OnInitializeCompletedfor backward compatibility.[-]Binding context issue on android[/-][+]UserControl code-behind constructor is not called[/+]Add support for UnoSkipUserControlsInVisualTree msbuild property
Add support for UnoSkipUserControlsInVisualTree msbuild property
Add support for UnoSkipUserControlsInVisualTree msbuild property
Add support for UnoSkipUserControlsInVisualTree msbuild property
Add support for UnoSkipUserControlsInVisualTree msbuild property
Add support for UnoSkipUserControlsInVisualTree msbuild property
feat: Set UnoSkipUserControlsInVisualTree to false by default
feat: Set UnoSkipUserControlsInVisualTree to false by default
feat: Set UnoSkipUserControlsInVisualTree to false by default
Merge pull request unoplatform#61 from unoplatform/pj/android-splash
chore: MOAR LOGGING
chore: MOAR LOGGING