Avatar of htn5ca
htn5ca

asked on 

Silverlight MVVM bind usercontrol to width/height

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.
.NET ProgrammingC#

Avatar of undefined
Last Comment
htn5ca
Avatar of saragani
saragani

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
Avatar of htn5ca
htn5ca

ASKER

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.  
ASKER CERTIFIED SOLUTION
Avatar of htn5ca
htn5ca

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of htn5ca
htn5ca

ASKER

I figured it out!
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo