Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • ctthang 4:57 am on March 4, 2011 Permalink | Reply

  • ctthang 3:37 am on October 20, 2010 Permalink | Reply
    Tags: VS Extensibility   

    VS 2010 Package Development – Chapter 1: Visual Studio Packages

  • ctthang 3:34 am on October 20, 2010 Permalink | Reply
    Tags: Scrum, TFS   

    Microsoft How-To: Scrum for Everyone

  • ctthang 6:21 am on October 1, 2010 Permalink | Reply  

    Dependency Property 

    • Dependency properties are just like other standard CLR properties that you
    declare on your classes, but they have additional features that extend their utility
    in the Silverlight environment (or more specifically cater to XAML’s demands).
    • Dependency properties are needed to support some of Silverlight’s advanced
    features, such as data binding and animation.
    • The most important features they support include evaluating markup extension
    expressions at runtime and automatically notifying bound controls when their
    value changes.
    • Although dependency properties are declared as static properties, their values are
    maintained per object instance, just like standard CLR properties. When you call
    the GetValue or SetValue methods, you are calling them on an object instance;
    therefore, the dependency system knows which object instance the value relates
    to and can get or set the corresponding value accordingly.
    • Dependency properties and their values are managed by the dependency system.
    Therefore, the developer does not need to create a member variable to maintain
    the property value for the class. Instead, the dependency system maintains these
    values in a hash table, and you ask it to get or set a property value using the
    GetValue or SetValue methods.
    • Even though it isn’t required, dependency properties are generally wrapped in
    standard CLR properties (which call the GetValue and SetValue methods) to more
    simply get or set their values in code.
    • These standard CLR property wrappers should not have any logic in their getters
    and setters.

    Dependency Property Code snippets :

  • ctthang 9:10 am on September 30, 2010 Permalink | Reply  

    Data binding examples in Siverlight 4 

    Using the Binding’s Source Property
    <TextBox Text=”{Binding Name, Source={StaticResource productResource}}” />

    ElementName Binding
    <TextBox Name=”FirstTextBox” />
    <TextBox Name=”SecondTextBox” Text=”{Binding Text, ElementName=FirstTextBox}” />
    The following XAML demonstrates taking the ItemsSource property of a ListBox control (acting as
    the target), and binding it to the Data property of a DomainDataSource control:
    <ListBox ItemsSource=”{Binding ElementName=productSummaryDDS, Path=Data}” />

    RelativeSource Binding
    <TextBox Text=”{Binding Path=CurrentItem}”
    ToolTipService.ToolTip=”{Binding Text,
    RelativeSource={RelativeSource Self}}” />

    Defining Resources in the Code-Behind (For Binding To)
    this.Resources.Add(“WebContext”, WebContext.Current);
    <Button Content=”Click Me!”
    IsEnabled=”{Binding Path=User.IsAuthenticated,
    Source={StaticResource WebContext}}” /> <– This is binding via nested properties (User.IsAuthenticated)

    Binding to Nested Properties
    <TextBox DataContext=”{StaticResource personResource}”
    Text=”{Binding Name.FirstName}” />

    Binding to Indexed Properties
    <TextBox DataContext=”{StaticResource personResource}”
    Text=”{Binding Address[0].AddressLine1}” />
    If the collection has string indexes (such as a Dictionary<string, string>), you can refer to the item
    using the string index syntax, like so:
    <TextBox DataContext=”{StaticResource personResource}”
    Text=”{Binding Address[HOME].AddressLine1}” />
    where HOME is the string index of the Address object to return.

    Binding to Objects in a PagedCollectionView
    public class SampleData
    public PagedCollectionView PeopleView { get; set; }
    public SampleData()
    List<Person> people = new List<Person>();
    people.Add(new Person() { Name = “Homer” });
    people.Add(new Person() { Name = “Marge” });
    people.Add(new Person() { Name = “Bart” });
    people.Add(new Person() { Name = “Lisa” });
    people.Add(new Person() { Name = “Maggie” });
    PeopleView = new PagedCollectionView(people);
    <models:SampleData x:Key=”sampleDataResource” />
    <StackPanel DataContext=”{Binding Path=PeopleView,
    Source={StaticResource sampleDataResource}}”>
    <ListBox ItemsSource=”{Binding}” DisplayMemberPath=”Name”
    Height=”120″ Width=”120″ />
    <TextBox Text=”{Binding Name}” Width=”120″ />

    Binding to Objects in a CollectionViewSource
    public class SampleData
    public CollectionViewSource PeopleViewSource { get; set; }
    public SampleData()
    List<Person> people = new List<Person>();
    people.Add(new Person() { Name = “Homer” });
    people.Add(new Person() { Name = “Marge” });
    people.Add(new Person() { Name = “Bart” });
    people.Add(new Person() { Name = “Lisa” });
    people.Add(new Person() { Name = “Maggie” });
    PeopleViewSource = new CollectionViewSource();
    PeopleViewSource.Source = people; }
    <StackPanel DataContext=”{Binding Path=PeopleViewSource,
    Source={StaticResource sampleDataResource}}”>
    <ListBox ItemsSource=”{Binding}” DisplayMemberPath=”Name”
    Height=”120″ Width=”120″ />
    <TextBox Text=”{Binding Name}” Width=”120″ />

  • ctthang 2:34 am on September 30, 2010 Permalink | Reply
    Tags: Note   

    Managed Extensibility Framework Overview

  • ctthang 10:39 am on September 25, 2010 Permalink | Reply  

    Hello Microsoft Pex 2010 

    Microsoft Pex 2010 is a Visual Studio add-in that provides runtime code analysis for .NET code. With just a few mouse clicks, you can:
      Explore code-under-test to understand input/output behavior in the code.
      Save automated tests that increase your confidence that your code can not crash—or point to errors that do cause crashes.
      Write powerful parameterized unit tests and generate suites of tests that ensure the code-under-test behaves as intended.

    Ok let’s start from the scratch.

    • Add a class containing some of methods: (“perfect” and “stupid”  methods)

    – Explore a method: Right click on a method that we want to explore, we can see the “Run Pex” menu item in Context menu.

    Click on “Run Pex” to explore the selected method.

    Great! Pex explores 6 cases in result and all of them are passed without exception.

    Try to explore a “stupid” method:

    Pex lists a lot of failed cases for the “stupid” method so this is a good way to check if there is any mistake in a method.

    Generate parameterized unit tests from Pex Exploration Results

    • Select all cases and click “Promote…”

    Click OK button on “Add new test project” dialog

  • ctthang 3:50 am on August 31, 2010 Permalink | Reply  

    Json.NET 3.5 Release 8

  • ctthang 3:29 pm on August 2, 2010 Permalink | Reply  

    Hello WCF world !!! 

    To get started, in Visual Studio 2008 select File | New | Project to display the New Project dialog box. In the list of project types, select WCF, displaying the list of templates

    Select WCF Service Library to create a WCF service

    Service Contract

    public interface IService1
    string GetFullName(Person person);

    public class Service1 : IService1
    public string GetFullName(Person person)
    if (person == null)
    throw new NullReferenceException(“person must not null!!!”);
    return string.Format(“{0} {1}”, person.FirstName, person.LastName);

    Data Contract

    public class Person

    public string FirstName { get; set; }

    public string LastName { get; set; }

    Test the service

    F5 to test the service

    Host the service using a Web server

    In the Solution Explorer, right-click the HelloWorld solution and select Add | New Web Site to display the Add New Web Site dialog box. Select WCF Service in the Templates list. In the Location text box, enter the solution’s folder and then append \HelloWorldWebHost to the folder name. Click OK.

    In the App_Code folder. Visual Studio created the IService and Service files but we should user a wcf service library instead because it provides for maximum reuse. So delete the IService and Service files 🙂

    Right-click the HelloWorldWebHost project, and select Add Reference from the context menu. In the Projects tab of the Add Reference dialog box, select HelloWorld. Click OK to add the reference to the service and change the contents of Service.svc file to the following:

    <%@ ServiceHost Service= “HelloWorld.Service1″ %>

    Open Web.config file and change Services section

    <service name=”HelloWorld.Service1″



    address=”” binding=”wsHttpBinding”



    <dns value=”localhost”/>



    <endpoint address=”mex” binding=”mexHttpBinding”



    In the Solution Explorer, right-click on Service.svc and select View in Browser see the service test page in web browser

    Consume the WCF Service in ASP.NET web site



  • ctthang 2:59 pm on July 31, 2010 Permalink | Reply

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc