Click here to Skip to main content
15,886,689 members
Articles / Web Development / ASP.NET

List vs ObservableCollection vs INotifyPropertyChanged in Silverlight

,
Rate me:
Please Sign up or sign in to vote.
4.60/5 (90 votes)
21 Sep 2009CC (ASA 2.5)2 min read 367.3K   5.7K   110  
This article gives a basic understanding of List, ObservableCollection, and INotifyPropertyChanged.
  • sllistvsobservablecollection.zip
    • SLListVsObservableCollection
      • SLListVsObservableCollection.gpState
      • SLListVsObservableCollection.sln
      • SLListVsObservableCollection.suo
      • SLListVsObservableCollection.Web
      • SLListVsObservableCollection
        • App.xaml
        • App.xaml.cs
        • Bin
          • Debug
            • AppManifest.xaml
            • de
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • es
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • fr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • it
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • ja
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • ko
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • Microsoft.Windows.Controls.DataVisualization.dll
            • SLListVsObservableCollection.dll
            • SLListVsObservableCollection.xap
            • System.ComponentModel.DataAnnotations.dll
            • System.ComponentModel.DataAnnotations.xml
            • System.Windows.Controls.Data.dll
            • System.Windows.Controls.Data.Input.dll
            • System.Windows.Controls.Data.Input.xml
            • System.Windows.Controls.Data.xml
            • System.Windows.Data.dll
            • System.Windows.Data.xml
            • TestPage.html
            • zh-Hans
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
            • zh-Hant
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Data.resources.dll
        • Page.xaml
        • Page.xaml.cs
        • Properties
        • SLListVsObservableCollection.csproj
        • SLListVsObservableCollection.csproj.user
<UserControl
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:charting="clr-namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.Windows.Controls.DataVisualization"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="SLListVsObservableCollection.Page"
    Width="Auto" Height="Auto" mc:Ignorable="d">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="51" />
            <RowDefinition Height="179" />
            <RowDefinition Height="300" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="333"/>
            <ColumnDefinition Width="325.5"/>
        	<ColumnDefinition Width="342"/>
        </Grid.ColumnDefinitions>
        
        <data:DataGrid x:Name="dgList" Grid.Row="1" Grid.Column="0" Margin="32,0,29,-6" />
        <charting:Chart x:Name="cList"  Grid.Row="2" Grid.Column="0" Title="Live Chart" Margin="32,0,29,99">
            <charting:Chart.Series>
                <charting:ColumnSeries DependentValueBinding="{Binding Path=Grade}"
                                    IndependentValueBinding="{Binding Path=Name}" />
            </charting:Chart.Series>
        </charting:Chart>
        
    	<data:DataGrid x:Name="dgOC" Grid.Row="1" Grid.Column="1" Margin="31,0,22,-6" />
    	<charting:Chart x:Name="cOC"  Grid.Row="2" Grid.Column="1" Title="Live Chart" Margin="31,0,22,99">
    		<charting:Chart.Series>
    			<charting:ColumnSeries DependentValueBinding="{Binding Path=Grade}"
    				IndependentValueBinding="{Binding Path=Name}" />
    		</charting:Chart.Series>
    	</charting:Chart>
        
    	<data:DataGrid x:Name="dgNPC" Grid.Row="1" Grid.Column="2" Margin="33,0,37,-6" />
    	<charting:Chart x:Name="cNPC"  Grid.Row="2" Grid.Column="2" Title="Live Chart" Margin="33,0,37,99">
    		<charting:Chart.Series>
    			<charting:ColumnSeries DependentValueBinding="{Binding Path=Grade}"
    				IndependentValueBinding="{Binding Path=Name}" />
    		</charting:Chart.Series>
    	</charting:Chart>

    	<TextBlock Margin="116,14,107,8" Text="List&lt;T&gt;" TextWrapping="Wrap" FontSize="20" FontWeight="Bold" d:LayoutOverrides="Height"/>
    	<TextBlock Margin="17,14,22,8" FontSize="20" FontWeight="Bold" Text="ObservableCollection&lt;T&gt;" TextWrapping="Wrap" d:LayoutOverrides="Height" Grid.Column="1"/>
    	<TextBlock Margin="33,14,22,8" FontSize="20" FontWeight="Bold" Text="INotifyPropertyChanged" TextWrapping="Wrap" Grid.Column="2" d:LayoutOverrides="Height"/>

    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-ShareAlike 2.5 License


Written By
Technical Lead Infosys
India India
Working as a Technology Lead in Infosys at Chennai, India.

Written By
Software Developer iSOFT
India India
Working as a Software Engineer in iSOFT at Chennai, India.

Comments and Discussions