-
Tell me if I am wrong: Expected Behavior: The BindingContext of the Skia control should not be reset when added to the visual tree. Code Sample:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @sferhah. Maybe i am wrong but this is intended behaviour you can adjust for your needs.
I see your main problem occurs when you add your layout to canvas, and canvas sets its context. so you can have a custom wrapper denying this context: Would suggest to always use a wrapper layout inside canvas even you want to use just one control, like button or label. Why? For potential overlays and to be able to cache your control when it has some surrounding stuff like shadows. In this case you would add a margin to your control with shadows and cache the wrapper, so the whole will not be redrawn everytime MAUI wants it too, it would just redraw cache in no time. public class Wrapper : SkiaLayout
{
public override void SetInheritedBindingContext(object context)
{
//i deny your context:
//wll not be calling base
//base.SetInheritedBindingContext(context);
}
} Then wrap your button inside the Wrapper, do something, then add wrapper to canvas. |
Beta Was this translation helpful? Give feedback.
-
Please feel free to ask more questions and raise up issues, would be glad to help. Will be closing this one now. |
Beta Was this translation helpful? Give feedback.
-
I tried migrating some code to DrawnUi and encountered the issue. I expected it to behave the same as with classic Maui controls. I fixed it by assigning the BindingContext after adding the view. It seemed odd, so I posted it here, thinking it might not be intended. |
Beta Was this translation helpful? Give feedback.
Hi @sferhah. Maybe i am wrong but this is intended behaviour you can adjust for your needs.
I see your main problem occurs when you add your layout to canvas, and canvas sets its context. so you can have a custom wrapper denying this context:
Would suggest to always use a wrapper layout inside canvas even you want to use just one control, like button or label. Why? For potential overlays and to be able to cache your control when it has some surrounding stuff like shadows. In this case you would …