Developing For .NET

Real World .NET Methods, Tricks, and Examples

Archive for August, 2009

Updated Community Schedule

Howdy folks,

I recently posted my fall community schedule.  Since then there have been a couple of confirmations and additions.

RDU Code Camp

This will be my first year going to Raleigh for RDU Code Camp.  RDU Code Camp is September 19th at ECPI in Raleigh, NC. I’ve heard nothing but great things, so I am really looking forward to it.

I will be presenting on “Templating and Data Binding in Expression Blend.”  I really enjoy speaking on this topic.  I find Templating and Data Binding to be the crown jewels of WPF, and as always Blend is there to smooth the way.

Richmond Code Camp

Richmond Code Camp, aka RCC2009.2, will be held October 3rd at J. Sargeant Reynolds Community College.  This is a great venue and one of my favorite events of the year.

I will be giving my presentation “Using Visual Studio and Blend to Develop WPF Applications.”  If you are new to WPF/Silverlight and or Blend, this is the presentation for you!  I will cover the basics of setting up an application, using Blend to develop the user interface, and how to use the two products simultaneously.

I will be retiring this presentation after RCC, so if you haven’t seen it yet this is your last chance!  If you have seen it, I promise it is a little different every time I give it, and of course it has been updated for Blend 3.

CapArea Silverlight Special Interest Group

I am slated to speak at the CapArea Silverlight Special Interest Group (SIG) at their October 28th meeting. We have not decided on a topic yet, but rest assured it will be Blend and Silverlight oriented!

Get out there!

As always, I really want to encourage you to get out into the community.  I promise that somewhere not so far away from you is a User Group, Code Camp, or other great event that you can take attend. 

You can always find more events all over the country at Community Megaphone, so do yourself a favor and get yourself to an event! I hope to see you around the community.

1 comment

How to Center a Silverlight App in HTML

I’ve written a lot of CSS over the years, so when I wanted to center my Silverlight App in my web page I figured it would be a piece of cake.  It is easy, but it gave me some frustration because it required one element that I normally would not specify.  Read on for the details.

Setting up the CSS

Here is the default CSS created by Visual Studio:

<style type="text/css">
html, body {
    height: 100%;
    overflow: auto;
}
body {
    padding: 0;
    margin: 0;
}
#silverlightcontrolhost {
    height: 100%;
}

To accomplish this little trick I need to define a wrapper DIV in my CSS.  This Div will then wrap the entire contents of the site, so now I only have to center that DIV.  We need to define the width of the content area: it makes sense that you want to set the size of something you want to center so it can be calculated.  To do this, I set the width property of the wrapper DIV to the pixel width of my Silverlight control.

Since not all browsers interpret things the same way, we need to add a couple of items in order to center our content.  First, add text-align: center; to the body tag.  This should handle the centering for IE browsers, at least older ones.  For Firefox and Safari, we need to add margin: 0 auto; to our wrapper DIV.

This is my typical set up in traditional HTML scenarios, but when I tried using this CSS the Silverlight object would not show.  I had some video in this particular example, and it was a good thing I did or I would have gone crazy trying to figure this out: I could hear the video playing, so I knew the Silverlight object was running, I just couldn’t see it.

It turns out that you need to specify the height property as well in the wrapper DIV.  It doesn’t have to be exact, just larger than your Silverlight control.  If you make it larger than 0 but smaller than your control, it will actually truncate the control, which could be an interesting effect in certain scenarios.  I don’t know the reason for this, perhaps it’s because the Silverlight control runs in an object tag, but I’m not sure.  Please post in the comments below if you know why this was required.

Here is the final CSS I used:

<style type="text/css">
html, body {
    height: 100%;
    overflow: auto;
}
body {
    padding: 0;
    margin: 0;
    text-align: center;
}
#wrapper
{
    margin: 0 auto;
    width: 800px;
    height: 800px;
}
#silverlightcontrolhost {
    height: 100%;
}
4 comments

Rants and Raves #6

Have you ever had a problem you couldn’t complain about?  Me too.  I have been so busy I haven’t had much time to post.  Between working like mad on a new project at work, learning several new technologies, traveling to Nashville for my first DevLink 2009, and a super-secret side project I’ve just been too swamped to post.

And I can’t complain: being this busy is a good thing, especially in this economy.

Rants

nHibernate – first crack

I was finally given the impetus to learn nHibernate, which I had heard about but never tried.  I’ve always assumed that cool kid tools like these are not for me since I am currently married to the AS/400 as a database.  I found at this past weekend, though, that I can in fact connect to the AS/400 using nHibernate, so I could finally have a decent OR/M tool for our database.  Getting rid of straight ADO.NET would be a dream come true!

Back at work this week, one of the first things I wanted to dive into was of course nHibernate, so I downloaded the code and began following the example touted on the nForge site.  The article is long and seemingly thorough, but it suffers from some serious organizational flaws. As I worked through it, my experience was decidedly different than the article suggested, although I was able to get it working with the help of the comments thread and a lot of Binging.

My biggest issue was the apparently recent requirement for adding a “proxyfactory.factory_class” xml element in the hibernate.cfg.xml file.  After doing so, you’ll find that you require a reference to NHibernate.ByteCode.LinFu.dll, which was not included in the SharedLibs list in the article.  After that, you’ll discover that you also require a reference to LinFu.DynamicProxy.dll, also not included in the SharedLibs list.  You can find both of these in the nHibernate subdirectory Required_For_LazyLoading/LinFu. (This can be altered to use Castle or Spring, both of which are included in the download).

I know I’m picking on one article, but if it is your go to “Hello World” demo, I expect it to be more refined.  Not to mention, it shows a lot but explains little.  I think it is especially difficult for someone with very little Unit Testing experience. There is going to be a lot of work ahead to grok the application, but so far it seems worthwhile.  Now I just need to get it hooked into my AS/400 and see if I can do some real work.

Raves

DevLink 2009

My list of “must-attend” Community Events is growing at a rapid pace, a little too rapid based on how busy I am, but what’s a geek to do?

This event was a little different than usual: my community buddy Kevin Griffin and I took our wives along to Nashville.  We had a great time, usually the two of us at conference and the two of them out sight-seeing.  I did get to go to the Gibson Showcase, where they make all the Gibson Mandolins, and the Country Music Hall of Fame.  My trip ended on a bit of a sour note: our family van of 10 years passed away and we had to get a rental for the ride home.

But the event was great!  As always, Open Spaces rocked, and I also saw some great presentations, which leads me to my next rave…

Shawn Wildermuth

Today is a first for Rants and Raves: I am raving about an individual person.

If you are remotely interested in Silverlight you’ve probably heard of Shawn Wildermuth.  C# MVP, INETA Speaker, Silverlight Insider, author, speaker, teacher, and much more: Shawn is a Tour de Force when it comes to Silverlight.

Fortunately for me, he was not only present at DevLink, but he sat in on my Open Space session about Silverlight.  I really appreciated the chance to discuss Silverlight up close and personal, and he gave me some great ideas for moving forward with my project. 

I then got to see his presentation called “Silverlight + MVVM = Easy”.  Meeting Shawn and learning at the foot of the master was the highlight of the trip for me (followed closely by getting to play a $25,000 Gibson F-5 Distressed Master Model” mandolin!)

I really admire that he is so involved in the community and that he freely shares his knowledge and skills. Thanks Shawn!

1 comment

Buying Expression Studio 3

I think Expression Studio 3 is now available: the website has switched from "pre-order" buttons to "buy" and "upgrade".

Kevin pointed out that MSDN is the way to go, which I agree with if it is an option, but I have Visual Studio Professional with MSDN Professional, which is $1,199: Expression doesn’t become downloadable until you have Visual Studio Professional with MSDN Premium which is $2,499. It’s just not worth it to me to spend an additional $1,300.

Studio Pricing

Expression Studio 3 costs $599 for the full version or $349 for an upgrade.  If you don’t have MSDN or anything like it, they have a good deal going though with "Expression Professional Subscription":

  • Expression Blend + SketchFlow
  • Expression Web
  • Expression Design
  • Expression Encoder + IIS Smooth Streaming
  • Visual Studio® Standard
  • Office Standard
  • Office Visio® Professional
  • Windows® XP
  • Windows Vista® Business Edition

All for only $999. I wonder if they’ll include Windows 7 now that it’s RTM?  And what happened to Expression Media?  It is no longer listed on the site.  No loss for me since I never used it, but I am curious.

Microsoft Action Pack Subscription

Through the Partner program, I was getting Expression Studio 2 via our Microsoft Action Pack (MAPS) subscription (specifically as part of the web solutions toolkit).  With MAPS I have to wait until they ship it to get the software, so I emailed the MAPS team the other day and asked if they knew when it would be available but they said they were not sure when the product would be released.

Today I checked the MAPS information online and they are now only advertising Expression Web, Design, and Encoder.  So it looks like I’ll probably end up buying the upgrade.  I’m a little surprised I can’t just update Blend, but apparently they aren’t selling the pieces individually except for Expression Web.

I’ve said for sometime that Microsoft should be giving Blend away if they really want to promote the adoption of WPF and Silverlight.  I wonder how many developers are sticking with Visual Studio because they don’t have access to Blend?

UPDATE:

The Luddite Developer is talking about this as well.  Seems he is in the same boat as me as far as MSDN goes.

I tried to call the MAPS team yesterday to get clarification on whether or not Expression Studio was going to continue to be part of MAPS, and also an update on when Expression 3 might ship.  The phone number given to me by Microsoft -I had called MSDN earlier and been given the number – had an interesting message:

“The number you have dialed has a new national directory service. For a charge of $3.79 please dial this new number …”

You want what?  You want me to pay to dial a new number?  Wow – if this was a rant I could fill it up… either MSDN gave me a bad number or MAPS is now charging for the privilege of calling them.

No comments

Is The Blend 3 Trial Worth The Download?

If you’ve spoken with me at any time over the last year at a technical conference or User Group you’ll know that I can’t go more than a few minutes without mentioning Microsoft Expression Blend. 

I was first introduced to WPF in 2006 and I was stunned by the results.  I couldn’t wait to try it myself, but at the time all I saw was XAML, and frankly I had no desire to develop business apps in markup.  Fortunately, in 2007 I saw Blend 1.0 and the flood gates opened: I had to have it, and I soon did.  Since then I have become a Blend evangelist.  It is my mission to preach the rich chocolaty goodness of Blend to all the people of the land.

OK, that may seem overkill, but in all honesty I cannot see developing WPF or Silverlight apps without Blend.  If I had to code strictly in XAML I would still be a Windows Forms developer.  Don’t get me wrong, plenty of people have done meaningful work without Blend, but I would never be one of them.

Is the Blend 3 trial worth the download?

Naturally, Blend is my current topic of choice for presentations, and I get plenty of questions about Blend from fellow developers.  This morning I received a question that I thought deserved sharing:

Are the blend 3 features worth the trouble of installing the trial version? Or wait for the official release?

This is a great question!  The requestor is currently using Blend 2 and wants to know if the updates from Blend 2 to Blend 3 are so awesome that they must have them now, or can they wait until GA.

My answer is, in typically non-committal fashion, “it depends.”

If you are dabbling with Blend and WPF or Silverlight 2, then you do not need to rush out and try Blend 3.  Don’t get me wrong, you could still benefit from it, but I wouldn’t consider it urgent.  You can wait for the RTM. 

[NOTE: If you are working on Silverlight 2, be sure to read all the warning labels before moving to Silverlight 3: you can’t go backwards once you install the Silverlight Tools for VS 2008.  In your case, you need to wait for VS2010, which is supposed to allow both environments.]

If you are a dedicated WPF or Silverlight developer/designer, by which I mean the bulk of your projects fall into one of these two categories, then by all means you should be using Blend 3 already.  You can install Blend 3 alongside Blend 2 with no ill effects. 

My Favorite Features

I spend a great deal of my time in Blend, and now even more so with Blend 3.  Here are the list of features I use the most in Blend 3:

  • Vastly improved Data tab (including SampleDataSource and easier databinding)
  • VSM for WPF (mostly built in, still need to add a reference to WpfToolkit.dll)
  • Artboard integration is finally usable – you can actually click on
    the element you want to use
  • The BreadCrumb makes working with Templates a lot easier
  • Code Editor – now you can edit C# inside Blend, including Intellisense.  I don’t advocate it for serious coding, but simple changes and events are quite feasible

There are probably more, but these are the ones that seem to most enhance my daily experience.  There are, of course, some bigger fish to fry that I have yet to really take advantage of like Behaviors and SketchFlow.

Conclusion

If you are in a position to do so, I would try Blend 3.  Trial downloads of Expression Studio 3 are available for 60 days, and pre-order purchasing is currently available.

I’ll be writing more about these features in future posts.  I’d like to add some Video Tutorial too, so feel free to leave requests in the comments below.

2 comments

Next Page »