title: How to bind a read-only WPF control property (eg ActualWidth) so its value is accessible in the view model?
body: <p>I want to bind a read-only property of a control to my view model so that the value is available in the view model.</p>
  
  <p>What is the best way of doing this?</p>
  
  <p>For example I'd like to bind <code>ActualWidth</code> to a property in my view model.  The width value is generated by WPF using its layout logic so I can't generate this value in my view model and push it to the control property, as would normally be the case.  Instead I need to have WPF generate the value and push it to the view model.</p>
  
  <p>I would just use <code>Mode=OneWayToSource</code>, but this doesn't work for read-only properties:</p>
  
  <pre><code>  &lt;Border
        ...
        ActualWidth="{Binding MyDataModelWidth, Mode=OneWayToSource}"
        &gt;
        ... child controls ...
    &lt;/Border&gt;
  </code></pre>
  
  <p>The way I am doing it currently is to handle <code>SizeChanged</code> for the border and the code-behind plugs the value into the view model, but this doesn't feel quite right.</p>
  
  <p>Has anyone already solved this problem?</p>
  
  <p>UPDATE:
  My question is effectively a duplicate of this one:
  <a href="https://stackoverflow.com/questions/1083224/pushing-read-only-gui-properties-back-into-viewmodel">Pushing read-only GUI properties back into ViewModel</a></p>