Deborah's Developer MindScape






         Tips and Techniques for Web and .NET developers.

December 20, 2010

Silverlight and Visual Studio 2010

Filed under: C#,Silverlight,VB.NET @ 4:29 pm

The Visual Studio tools are amazing, except when they don’t work. Then they cause limitless frustration and waste countless hours.

It is during these times of frustration that I find myself swearing at my favorite tool. But a few days later, when someone asks me about the problems I had, I only recall the frustration, not the broken features.

So as I launch into a big Silverlight project with Visual Studio 2010, I decided to start writing down all of the things I find that either don’t work or don’t work as expected or require some obscure trick or are missing entirely or just need improvement.

Here is today’s list:

Images in HyperlinkButtons

I thought it would take me a few minutes to add all of the images for my home page to the screen and make them navigable. But no. Here is the code I tried:

<HyperlinkButton x:Name="ReportsImageButton"
     Canvas.Left="253" Canvas.Top="160" Height="50" Width="50"
     HorizontalAlignment="Center" VerticalAlignment="Center"
     NavigateUri="/Reports" TargetName="ContentFrame">
     <HyperlinkButton.Content>
       <Image
     Source="/MyProject.SL;component/Assets/Resources/Overview.png" />
     </HyperlinkButton.Content>
</HyperlinkButton>

Turns out that an image cannot be the content of a HyperlinkButton as reasoned here. You can set the image as the background of the HyperlinkButton as shown below:

<HyperlinkButton x:Name="ReportsImageButton"
     Canvas.Left="253" Canvas.Top="160" Height="50" Width="50"
     HorizontalAlignment="Center" VerticalAlignment="Center"
     NavigateUri="/Reports" TargetName="ContentFrame">
     <HyperlinkButton.Background>
        <ImageBrush 
   ImageSource="/SCStar.SL;component/Assets/Resources/Overview.png" />
     </HyperlinkButton.Background>
</HyperlinkButton>

Or you can use a StackPanel or Border within the HyperlinkButton and put the image inside the StackPanel or Border.

XAML Code Formatting

I like my code to be organized. It is extremely frustrating when the XAML Code Editor keeps moving my code around. Yes, I did mean to put in two tabs. Why does the editor keep shifting the text further to right every time I edit it? Or suddenly decide to move a set of lines to the left? Can’t it just leave my code formatting alone?

StaticResource Intellisense and Navigate To

When I add a property to an element, I get nice intellisense to help me select the appropriate property value. This is very nice:

image

I would like to see the same thing when selecting a StaticResource. While on this topic, I would like to see a right-click Navigate To Definition feature that would navigate to the resource definition.

The hope is that by identifying these types of issues in our beloved tool, we can help to make it better.

Enjoy!

2 Comments

  1.   Mark Shiffer — December 21, 2010 @ 3:03 pm    Reply

    I can’t believe Microsoft didn’t put the right click/navigate to feature in the initial release. That one is such a productivity sink when working with WPF.

  2.   Zain Shaikh — December 26, 2010 @ 1:28 pm    Reply

    Goood post.

    I agree, I would also ‘want to see the same thing when selecting a StaticResource’. and also the ‘right-click Navigate To Definition feature that would navigate to the resource definition’

RSS feed for comments on this post. TrackBack URI

Leave a comment

*

© 2014 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs