title: WPF MVVM binding controls with helper methods PDFTron PDFViewer
body: <p>I am struggling with a WPF MVVM problem using a control that has helper functions and exposing those helper functions to my viewmodels.</p>
  
  <p>I am using the PDFTron viewer control that shows a PDFDocument object. Items in that PDFDocument are specified in terms of a PDFTron.Rect structure with the elements measured in points(1/72th inch) and a page number</p>
  
  <p>To help convert the coordinate systems to and from screen position the PDFTron  ViewerControl has various function on itself.</p>
  
  <p>e.g. To convert from a screen point</p>
  
  <pre><code>Double x, y;
  int page = Control.GetPageNumberFromScreenPt(x, y);
  Control.ConvScreenPtToPagePt(ref x, ref y, page);
  </code></pre>
  
  <p>To convert to a screen point is from the object being examined</p>
  
  <pre><code>PDFTron.Rect r = Control.GetScreenRectForAnnot(embeddedObject, pageNumber);
  </code></pre>
  
  <p>What the best way of calling/exposing or binding to functions like this between the view model(s) and the PDF control as I would really like to databind to coordinates. </p>
  
  <p>For instance I have an adorner defined in XAML that allows me to move an image I have read from the embeddedobject about the page by dragging and I can also resize the image.  The viewmodel knows As my view model knows the image the embedded object its page and Rectangle on that page, but as PDF coordinates.  But this needs to be translated to screen coordinates for the X, Y, Width and Height for binding to the XAML Attributes.  I cannot quite see how to do this as it seems beyond a dataconverter.  </p>
  
  <p>So the control in the xaml has attributes measured in screen units</p>
  
  <pre><code>AdornerLeft="{Binding Data.X, Mode=TwoWay}"
  AdornerTop="{Binding Data.Y, Mode=TwoWay}"
  AdornerWidth="{Binding Data.Width, Mode=TwoWay}"
  AdornerHeight="{Binding Data.Height, Mode=TwoWay}"
  </code></pre>
  
  <p>If the X and Y change I need the change to be reflected eventually as the page,x,y coordinates of the viewer as they are what are used by the underlying model.
  I did wonder would it be wise to make a series of dependency properties so if I change one it ripples the change through the others as a conversion?  So for example I have a property ScreenY When that changes it updates PDFY and PDFPage and vice versa but that seems overly complicated.  Any suggestions?</p>