Skip to content
apohl1111 edited this page Nov 4, 2011 · 20 revisions

XAML

Root Order

  1. x:Name, x:Class
  2. All references, maximum 2 per line
  3. Design properties (Ex. mc:Ignorable="d" d:DesignWidth="230" Foreground="Blue")
  4. ViewModelLocator?
  5. Bindings

Rules:

-Wrap lines when they pass more the longest reference line

Controls Properties Order

  1. x:Name
  2. Design properties
  3. Bindings

Example:

<Rectangle x:Name="rectangle1" Height="1" Width="200" Fill="{Binding FillColor}" />

Silverlight

The FoundOps code structure is broken into these sections

Code Structure

1-2 of something(like properties or methods): use //
3 or more: enclose in #region/#endregion

All comments should start capitalized and use proper punctuation.

Class Structure:

//Summary

Properties & Variables

-Public

-Protected

-Locals

Constructors (least parameters => most parameters)

Logic(Always in a region)

Example property:

//Summary
private int _num
public int Num
{
get{...}
set{...}
}

Logic Code Organization

Organize by:

  1. Code Execution
  2. Alphabetically

Example code execution section:

//Section explanation

//1st method called

//2nd method called
{
    //inner method A

    //inner method B
}

Using Statements

Try to keep in order of shortest to longest

Lambdas

When you don't need to use the variable, you can use _ => for one variable or (_,__) for multiple variables.

Example:

AddCommand.Subscribe(_ => UpdateFilter());

Commenting

Multiple Conditions

Separate the code like this:

// Update Filter whenever: a) routes are changed or is set, b) the SelectedRouteTypes changes,
// c) the SelectedRegions changes

var loadedRoutes = DataManager.GetEntityListObservable<Route>(Query.RoutesForServiceProviderOnDay);

//a) routes are changed or is set
loadedRoutes.FromCollectionChangedOrSetGeneric()
    //b) the SelectedRouteType changes
    .Merge(SelectedRouteTypes.FromCollectionChangedEventGeneric())
    //c) the SelectedRegions changes
    .Merge(SelectedRegions.FromCollectionChangedEventGeneric())

Easy Mistakes

Confusing seconds and milliseconds when using RX TimeSpan.

new TimeSpan(0,0,2) //2 seconds
new TimeSpan(0, 0, 0, 0, 300) //300 milliseconds  

See [http://msdn.microsoft.com/en-us/library/system.timespan.aspx](this link) for more information.

Clone this wiki locally