Jesse Johnston
.NET Dev. Good times with .NET and coffee

Silverlight 3 Navigation: My HyperlinkButtons don’t work!

Sunday, 17 January 2010 15:30 by jesse

The navigation framework of Silverlight 3 is great.  The URI mapping and browser history support add a lot of value.

When upgrading a Silverlight 2 site to use Silverlight 3 with navigation, I was surprised to see that all of my HyperlinkButtons that referenced external URLs were failing!

For example, a button with this XAML:

<HyperlinkButton Content="Microsoft" NavigateUri="http://www.microsoft.com"/>

when clicked yields this:

image

It turns out that once your HyperlinkButton is inside of a navigation frame (which it will be once you add navigation support to your application), you need to set the TargetName property of the button.  To preserve the Silverlight 2 behavior where the referenced URI loads in the same browser window, use “_self” as the TargetName:

<HyperlinkButton Content="Microsoft" NavigateUri="http://www.microsoft.com" TargetName="_self"/>

You can also use “_blank” to open up the page in a new browser window.

When using a HyperlinkButton to navigate to a Silverlight page internal to your application, TargetName should reference the name of the navigation frame:

<navigation:Frame x:Name="ContentFrame" Source="/home">
  <navigation:Frame.UriMapper>
    <uriMapper:UriMapper>
      <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
      <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
    </uriMapper:UriMapper>
  </navigation:Frame.UriMapper>
</navigation:Frame>
 
<HyperlinkButton NavigateUri="/about" TargetName="ContentFrame" Content="About Us"/>
 

HyperlinkButtons fixed!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:   .NET | Silverlight
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

.NET 101

Monday, 26 October 2009 05:10 by jesse

If you find yourself wanting yourself to share some C# brilliance related to…images

  • The difference between Object.Equals() and ==
  • How string comparison is an interesting special case
  • Why class instance memory is not necessarily reclaimed when an instance goes out of scope
  • Which of Stream.Close() and Stream.Dispose() should be called (or both)

Please remember that it is not 2001.  Everyone knows these things (unless you’re in a .NET 101 class).  If you don’t know these things…may I suggest .NET U?

Seriously, though – how about something interesting like harnessing the power of IObservable<T>?  Bring on the new!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

Doing the Dishes

Friday, 2 October 2009 03:13 by jesse

You DO want to do more than the minimum don't you?While washing all of the coffee cups left in the office sink by others this morning, I was reminded of a lot of code I’ve seen lately.

How often do you open up a piece of code in Visual Studio to find something implemented in a completely ad hoc way, or only half done?  Swaths of code commented out, TODOs sprinkled throughout, all sorts of unrelated concerns mixed in.

These are dishes in the sink.  Someone went home early to get their weekend started and left the work for someone else to do.  This attitude can’t be tolerated in an organization that wants to win.

When hiring, I always look for people who go beyond the minimum.  These are the people who not only deliver great, complete code, but also mentor, blog, and develop their own works.  People who show up early and leave late because they love what they do and have a hard time walking away.  People who wear more than 15 pieces of flair.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Where are the recent items in my Windows 7 jump list?

Thursday, 1 October 2009 11:49 by jesse

I just started adding support for the Windows 7 taskbar jumplist to my WPF application, using the excellent .NET wrappers in the Windows API Code Pack.

After creating the jump list, file selection via the Windows common file dialogs should automatically cause entries to appear in the Recent section of the jump list.

But no.  What's going on?

It turns out that everything is working as expected.  However, you need to have the "recent items" checkbox enabled for the taskbar:

 

 
Once clicked, the Recent items appear on the jump list. 
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:   .NET | WPF
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Scrolling TextBox in WPF

Thursday, 1 October 2009 03:03 by jesse

If you put a TextBox inside a ScrollViewer, the TextBox will take as much width as it needs, even if you set TextWrapping to Wrap.  That means that a long line of text will just stretch out to the right, beyond the right edge of the ScrollViewer, instead of wrapping.

Fortunately, you can bind the Width of the TextBox to the ScrollViewer ViewportWidth.  This makes the text wrap at the right edge of the ScrollViewer.  If you hide the horizontal scrollbar, you get just what you'd expect - vertical scrolling and horizontal wrapping.  This also allows the ScrollViewer to participate in a flow style layout and still have the text wrap correctly.

<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">

<TextBox IsReadOnly="True" FontSize="14" TextWrapping="Wrap" Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollViewer}}, Path=ViewportWidth}"/>

</ScrollViewer>

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:   .NET | Silverlight | WPF
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

code2plan Filters

Monday, 30 March 2009 02:31 by jesse

Yesterday Denis and I released a new version of code2plan that includes a couple of long-awaited features: filter and search.

We've had filters for some time, but they weren't fully functional.  Our new release supports some great new filtering capabilities:

  • Filters are persistent.  You can save your filters by name, and they appear in the filters popup for the appropriate work items page.  A filter is always associated with a specific kind of work item, like tasks or stories.  The filter selected for a work items page is also remembered, so if you select the "Backlog" filter on the stories page, you'll still be looking at the backlog when you return to that page later.
  • Filters can be shared.  Just like work items, if you create a filter, all the other users in your team can see and use it.  Unlike work items, filters can also can be private, so you can have your own special set of filters that is visible only to you.
  • Filters can be organized.  For each work item type, there is a list of all filters.  You also have a list of favorite filters for each work item type that is specific to you.  You can add and remove filters to this list, and move filters up and down in the list.
  • Filters have new special values.  Almost all work item properties can be filtered on.  Most properties are standard types, like string, decimal, and date.  You can filter on specific values for these types (including "not set").  Date properties can also be compared to special values "today", "in the future", and "in the past".  These values are special because they are always evaluated at the moment the filter is run.  That means that your filter results will automatically change over time as existing date values move into the past.  Work item properties that refer to iterations can be compared to the special value "current iteration", which refers to whichever iteration is selected on the dashboard.  Finally, the owner property can be compared to the "logged in user", which refers to whoever is currently logged in.  All this means that it is easy to construct a filter like "my iteration tasks" which looks for tasks owned by the logged in user for the current iteration.  This filter will always be relevant regardless of who is logged in or which iteration is current.
  • Predefined filters.  We've included a bunch of filters out of the box to get you started.  These filters automatically populate the favorites list on each page.

Note that the Dashboard and Stories pages no longer implicitly filter on current iteration.  You'll see all tasks and stories unless you select a filter.  The iteration combo box on the Dashboard still sets the current iteration, but this is only used for the "current iteration" special value in filters, and for the burndown chart.

A browser-style search box has also been added to each page.  Here you can enter one or more words, which will be searched for in the work item name, description, and comments properties.  All of the words must be found for a work item to match, but they can be found in any of the properties mentioned.  On the people page, the search is performed on the login, first name, last name, and email properties.

Note that when a filter is applied, search will only return results that are also included in the filter.  So, if you have a filter selected for open defects only, a search won't return any closed defects.

There are a few other enhancements and bug fixes.  Denis spent some time revamping the color schemes for our users on Windows XP (you've reported that the colors weren't the best).  See the release notes for all the detail.

I hope you like the new version - go to www.code2plan.com and download it now.  code2plan is free!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

code2plan Beta Release

Wednesday, 7 January 2009 16:48 by jesse

As a few of you might have seen, my side project code2plan is finally in beta.

code2plan is a free agile software project management application that is available as a Visual Studio 2008 add-in, and also as a standalone Windows desktop application.  Both versions have the same feature set, and both are WPF applications.  The program supports single users as well as supporting a shared database for teams.  You can work offline (no network connection required), and when you do sync up, a very straightforward conflict resolution feature helps you manage changes that you and other team members have made to the same data.

If you're an agile .NET developer, I would really appreciate your feedback on the program - both good and bad.  We'll be releasing new versions of the application very frequently, so there's a good chance that if code2plan doesn't work for you right now, it may very soon.  Just let me know.  Please post your comments to the forums on the code2plan web site so that everyone can benefit from the discussion.

I'll be posting here regularly over the coming weeks about the code2plan architecture, design thinking, and future plans.

Happy New Year!

Jesse

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Tags:  
Categories:   .NET | code2plan
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Using SQL Server 2008 Express as a default instance

Saturday, 13 September 2008 17:46 by jesse

Time to upgrade!  After uninstalling SQL Server 2005, I decided that I would try running only the Express version of SQL Server 2008 on my laptop.  After installing, I found that running SQLCMD against the (local) server no longer worked.  For example,

sqlcmd -s (local) -i SomeScript.sql

Resulted in this error:

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

I had installed SQL Server 2008 Express as the default instance (and I don't have any other version of SQL Server on this machine), and accepted the default instance name SQLEXPRESS.

SQLCMD is connecting to the instance through named pipes, and the pipe name it connects on for the default instance is \\.\pipe\sql\query

To connect to a named instance, it connects through the named pipe \\.\pipe\MSSQL$<instancename>\sql\query

Sure enough, after opening Sql Server Configuration Manager, I expanded the Sql Server Network Configuration, double-clicked on Named Pipes, and was able to see that the pipe name included the instance name SQLEXPRESS.  After changing the pipe name to \\.\pipe\sql\query, my sqlcmd reference to (local) worked great.  Whew.

Named Pipes Properties

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Tags:  
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | Comment RSSRSS comment feed

Architecture is important

Wednesday, 6 August 2008 16:17 by jesse

And not just in software!  But like design in buildings and furniture, software architecture is more than putting parts together so that everything works.  Software should be beautiful, classy and fun.  Ted Kamp and Mies Van Der Rohe obviously get that.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Moving My Blog

Saturday, 2 August 2008 10:45 by jesse

I changed my web hoster over the weekend, and when ran into a few snags migrating dasBlog to the new Windows Server 2008 / IIS7 environment.  While shoveling and wiring and taping, I found BlogEngine.NET.  Super cool.  It's a very simple and extensible .NET blogging platform.

To make a long story short, my blog is now running on BlogEngine.  I also changed the address to be a little easier on the eyes.  It's now www.teamjohnston.net/blogs/jesse (this is where you're at if you're reading this).  There's lots of new stuff coming soon...really.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed