Search code examples
macosxamarindynamicnsscrollviewxamarin.mac

Xamarin Mac NSScrollView with dynamic content


I want to add a unknown count of Custom Views to a NSScrollView within a Xamarin Mac application, but I cannot find a way to do this. On iOS I would create a UIScrollView containing a UIView containing a UIStackView which will automatically layout the controls.

I tried it like this:

var controller = (AudioViewController)Storyboard.InstantiateControllerWithIdentifier("AudioView");
var subview = controller.View;
stvFiles.AddArrangedSubview(subview);

the first view will be displayed, but needs the whole space, and the second view will not be visible.

How would one do it adding dynamically views to a NSScrollView?

Thanks in advance for your help!


Solution

  • Solution

    For everyone having the same problem, here is a solution i found. It was coded with Swift, but implementing it in C# is easy.