Silverlight MVVM bind usercontrol to width/height

htn5ca
htn5ca used Ask the Experts™
on
So I have my silverlight app which I have created but I need to take a value and compare it to the actual width/height of a usercontrol for ratio control.  Is there a way to only set the binding for "read only"?

I have this usercontrol.width and usercontrol.height that I want to bind to two different int values which would be the actual width and height of the usercontrol.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What do you mean by read only?

You can try using mode=OneWay when you define the binding.
This way, if the size of the usercontrol changes, it will not update the source

Author

Commented:
What I want is the opposite.  I want it only one way but from the usercontrol to the viewmodel.  If the usercontrol changes then the source will update.  The source will NEVER update the usercontrol as it is automatically done by the grid.  

So here is my scenario:
I have this usercontrol that I have created.  I have to get the ratio of the usercontrol against some physical size.  Since the usercontrol can be resized, I need to read the width and height values to calculate the correct ratio so I can scale everything inside the usercontrol accordingly.  All I want to do is just read usercontrol's width and height using binding.  
Commented:
ok I got it.  Since I have the usercontrol as a private property, i just hooked onto the SizeChangedEventHandler.  Then whenever the size changes, i can update my software.  

Author

Commented:
I figured it out!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial