in

WPF Design and Development

IdentityMine Team Blogs

David Kelley

A day in the life of a humble software architect... doing C#, WPF, Silverlight, Legos, Fuzzy Logic AI and/or whatever is the latest and greatest or more importantly the coolest techo mumbo jumbo...

Calculating Relative Perspective For Silverlight Xaml

So I touched on this earlier when I when over the JavaScript class structure for Silverlight classes.  So usually when I get a comp from a designer they are usually designed for a certain size say 400 by 600.  say there is some element in the block is 45 pixels accross.  So now I make my class out put all these bits into the xaml on the fly so the functionality is better contained in a class for reuse.  I want me UI to be able to be set to different sizes and have it look correct.  Todo that I need to calculate the relative width.  So at a width of 400 for the UI and the element is at a width of 45 needs to be reset when the width changes to 240.  So what I want todo is take the width and multiply it times some value that gives me the correct number to replace the 45.  So what I do is divide 45 by 400 to find the factor I need to be able to take the width whether its 400, 500 or just 180 and then multiply it by the factor.  So in code I might have something like this:

var ItemWidth = UIWidth * .1125;

and poof a got my width and my UI can be set to anything size I want and it looks correct.

 

Comments

No Comments

About david.kelley

David for the past 10 years has focused on distributed application design and emerging Microsoft technologies on the web. Having helped design and build some of the largest systems for companies like Microsoft, Onyx Software, Saltmine, Giordanous Group and more and of course our favorite company Identitymine, he has been on the leading edge of applying the latest tech to real world business problems. David’s technology breadth includes everything from SQL Server to Windows/WCF and Silverlight. David’s accomplishments also include developing new technologies such as self editing XML files and related XML technologies to fuzzy logic systems and advanced web user interface design.
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems