Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to disable horizontal scrolling of NSScrollView?

KyuubiKyuubi USMember ✭✭

Hi All,

My document view exceeds the horizontal extent of the screen and becomes scrollable. I need to enable or disable horizontal scrolling only when needed. Can anyone navigate me how to proceed with the same?

Thanks.

Best Answer

  • ColeXColeX Member, Xamarin Team Xamurai
    edited May 2019 Accepted Answer

    Since Forms does not provide this function ,so i'm afraid you have to use custom renderer.

    To disable the horizontal scrolling of NSScrollView , you could set the documentView property ,make the documentView width equals to screen width .

    Something like this

    //disable horizontal scrolling
    var contentView = new NSView(new NSRect(0, 0, screenWidth, Control.DocumentView.Height));
    Control.DocumentView = contentView;
    

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited May 2019 Accepted Answer

    Since Forms does not provide this function ,so i'm afraid you have to use custom renderer.

    To disable the horizontal scrolling of NSScrollView , you could set the documentView property ,make the documentView width equals to screen width .

    Something like this

    //disable horizontal scrolling
    var contentView = new NSView(new NSRect(0, 0, screenWidth, Control.DocumentView.Height));
    Control.DocumentView = contentView;
    
  • KyuubiKyuubi USMember ✭✭
    edited May 2019

    Hi @ColeX,

    Thanks for the answer. That works great as expected. However I also want to enable the diagonal scrolling which means the view has to be scrolled in 60 degree axis. Currently, I could only able to scroll either in horizontal direction or vertical direction one at a time but not simultaneously. Is it possible to do so?

    Thanks.

Sign In or Register to comment.