Mike's Picture Mike Uttech
Adventures in Life

You learn something new every day!

May 12, 2008 4:14 PM by Mike

I really thought I had found a magical solution that would eliminate all of my resizing code, but after experimenting with it, I don't think it's as good as I originally thought.

Using a Grid with a ratio of sizes set will automatically resize all non-absolute sized objects within it, which is exactly what I want.  The problem is, that for the layout I am doing, there's more than a few Rows and Columns needed, and some content needs to span all rows/columns (the background image) and some content needs to align within specific rows/columns.

To demonstrate what my layout looks like, and how items need to float, I put together a super creative looking diagram:

Maybe I am just missing something with the Grid control, but I think (for now atleast) I am going to stick to resizing/moving items on my own by subscribing to the SizeChanged event...


Tags:
Categories: Work
Actions: Permalink | Comments (0) |

Interesting technique for navigating between XAML files

May 9, 2008 11:50 PM by Mike

I was looking for a way to seperate out different "pages" within a Silverlight app, and stumbled upon a method to do just that at:

http://www.flawlesscode.com/post/2008/03/Silverlight-2-Navigating-Between-Xaml-Pages.aspx

It's a pretty simple, yet effective, concept.  On Application_Startup instead of setting the RootVisual to a new instance of Page, you set it to a new Grid control, and add a new Page as a child control of the Grid. 

In my case, I wanted to maintain a UI XAML that contains my elements that need to be repeated on each "page" (master page type XAML?)  To do so, I simply added another child control (my "page" XAML) and then I don't remove the initial Page reference from the RootVisual controls.

root = Application.Current.RootVisual as Grid;

UserControl oldPage = root.Children[0] as UserControl;root.Children.Add(

new Home());

//root.Children.Remove(oldPage); // This is where I don't unload the "oldPage" which in my case is my repeatable UI XAML.


Tags: ,
Categories: Work
Actions: Permalink | Comments (0) |

Silverlight and scaling to the browser dimensions

May 9, 2008 12:35 AM by Mike

I had a nice long post typed out, and while attempting to make a small change to the code I was going to paste in, I ended up killing the debug process that I had the post opened in a new tab, so as much as I remember will have to be retyped:

Recently our Flash projects have been given a requirement that they resize to the browser.  In the past, someone would pick a resolution (often times neglecting to account for the browser chrome) and the flash was done as a fixed width/height element.  The last 2 projects I've worked with have been required to scale with the browser.

One such project is the same one that I've decided to prototype in Silverlight.  It's the Donor Garden that we worked on for the National Marrow Donor Program® (which is a great organization, and you should really think about joining the registry and potentially saving someone's life!)

I really have taken for granted in the past 8 or so years that the browsers HTML rendering engine handles the repositioning of elements on a browser resize.  I really haven't had to think about this problem since my VB 4/5/6 days and developing Windows apps.  So tonight was a fun little stroll back down memory lane.

It's pretty straight forward, subscribe to the Canvas's SizeChanged event, and reposition/resize elements based on the new size.  The SizeChangedEventArgs contains both the new size and the old size, although I am currently only using the NewSize to get the Width and Height.

Here's the start of my code:

private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)

{

if (e.NewSize.Width < 778 || e.NewSize.Height < 450)

{

status.Text = "Elements need resized.";

}

if (e.NewSize.Width > GrassImage.Width)

{

GrassImage.Width = e.NewSize.Width;

}

GrassImage.SetValue(Canvas.TopProperty, e.NewSize.Height - GrassImage.Height - 32);

HeaderCanvas.Width = e.NewSize.Width;

FooterCanvas.SetValue(Canvas.TopProperty, e.NewSize.Height - 32);

FooterCanvas.Width = e.NewSize.Width;

}


Tags:
Categories: Work
Actions: Permalink | Comments (0) |

Finding projects to prototype

May 7, 2008 11:57 PM by Mike

Whenever I am trying to learn a new technology, I find myself needing to learn by example to actually understand how it all works.  My biggest problem with this is finding a good project that I can prototype/experiment with. 

Trying to learn more about Silverlight and what I can all do with it, I've been struggling to come up with a perfect application to develop.  I think I am going to take one of the projects we've done previously in Flash, and replicate the solution in Silverlight.  This should give me some good feedback on the development time difference (taking into account the learning curve for me to learn exactly what I am doing) and also give me a good side-by-side comparison when completed.

I hope to really demonstrate the strengths of Silverlight versus Flash development, especially from an agency standpoint.


Tags:
Categories: Work
Actions: Permalink | Comments (0) |