In my app I’ve got a custom view with sub views for printing. Populating it can take a while so I’m doing that when the user clicks print. This means the height and position of the views are set by the ViewWillDraw method which is triggered by the PrintOperation.RunOperation();
It all works fine with one caveat, the preview pane doesn’t immediately refresh. When the built in print panel shows it is initial blank. Clicking anything (eg copies button) forces a refresh and it previews correctly. I’ve discovered I need to use the KeyPathsForValuesAffectingPreview to tell the preview to refresh when something changed eg: view.frame size.
If I comment out the overriding of the ViewWillDraw method in my view class then the print preview shows but the framesizes are all wrong.
My issue is that I’m new to Xamarin Mac development and the limited documention I can find is objective C or swift and that syntax is alien to me.
What I haven’t been able to determine is where do I put this KeyPathsForValuesAffectingPreview code, is it an override? There is an example at https://github.com/brunophilipe/Noto/blob/master/Noto/View Controllers/Printing/PrintAccessoryViewController.swift
But that’s a print accessory which I don’t think I need and anyway I can fathom how to convert the syntax to equivalent c# syntax. It seems to be an extension but I’m not sure of which class to put it in as an extension nor the right syntax for declaring such an extension.
So my printing is working but I need to tell the built in print panel to refresh using KeyPathsForValuesAffectingPreview. Can anyone enlighten me with a sample of how to do this please?