Posts

Showing posts from October, 2009

Silverlight 3 Page Not Found error

I was working on a project when all of the sudden I started getting a “Page Not Found” error. Of course the page is there and it had been working fine. Turns out it was the templates infrastructure hiding the error from me. When you create a new SL Navigation Application, you’ll find the following in your MainPage.xml.cs. // If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { e.Handled = true; ChildWindow errorWin = new ErrorWindow(e.Uri); errorWin.Show(); } This nice little piece of code hides the real cause of the error so that all you see is Page Not Found. Bryant Likes has some code that will give you a better idea of the error. // If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { Exception ex = e.Exception; while (ex.InnerException != null) { ex =...

Nice Drop Shadow Border in XAML

I was working with Silverlight 3 and created this drop shadow border. Enjoy. <Style x:Key="DropShadow" TargetType="Border"> <Setter Property="Background" Value="WhiteSmoke" /> <Setter Property="CornerRadius" Value="5" /> <Setter Property="BorderThickness" Value="1,1,4,4" /> <Setter Property="Margin" Value="10" /> <Setter Property="Padding" Value="6" /> <Setter Property="BorderBrush"> <Setter.Value> <LinearGradientBrush> <GradientStop Color="#ccc" Offset="0" /> <GradientStop Color="#ddd" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style>

Using Interfaces, Generics and the Repository Pattern

Image
I’ve been using the repository pattern to insulate my apps from the LINQ to SQL so that I can easily change when (or if) MS kills L2S. The nice thing about this is that I can write a generic repository the encompasses some of the tasks so that the code is consistent for all repositories. A little background first. We name all our tables the plural of the objects contained and the first column is an integer primary key named in the singular followed by a “Key” suffix. For example, the Customers table has a first column of CustomerKey. This key name is then used in all related tables as the foreign key column. This makes it very easy to come in behind someone and figure out the data structure. This convention gets in the way of making life easier for me because all items have a different name for the primary key. To fix this, created an interface called IPrimaryKey, shown below. public interface IPrimaryKey { int PrimaryKey { get; set; } } In my database model, I change the...