Forum Xamarin Xamarin.Forms

Is it possible to override events of VisualElement class?

CaioshinCaioshin ITMember ✭✭

I would like to be notified when the IsVisible property of any UI elements change, debugging my app I saw that the OnIsVisibleChanged event of Layout.cs class (Xamarin.Forms.Core) is raised but it's not publicly exposed and I don't know how to attach to it.
I thought that I could override the VisualElement class, because the IsVisible property is inherited from this class, but I'm not sure if is possible and how to proceeed.
Any suggestion?
Thank you

Best Answers


  • CaioshinCaioshin ITMember ✭✭


  • CaioshinCaioshin ITMember ✭✭

    thank you, but I don't want to create a new class, instead I would use this feature on a standard control (ie on Image class).
    Is it possible?

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    There is a PropertyChanged event you can subscribe to as well.

  • CaioshinCaioshin ITMember ✭✭

    and in which class do have I to subscribe?

  • CaioshinCaioshin ITMember ✭✭

    I tryed your solution but seems to now works.
    If I override the OnPropertyChanged as suggested it show me an error because arguments are not corrects.

    If I declare the method with arguments expected, like this:

    private void Layout_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

            if (e.PropertyName == VisualElement.IsVisibleProperty.PropertyName)

    I have that the e.PropertyName is always "Y" event if I'm changing its visibility (it never go into OnVisibilityChanged).

  • CaioshinCaioshin ITMember ✭✭

    any help?

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    Maybe make a small project that replicates this and upload? At this point, it is probably just an error somewhere in your usage we cannot see from here.

Sign In or Register to comment.