My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.
9 hours ago: Here's a use-case for datapod format, recording human-readable data that later can be used as a datasource: http://is.gd/eSsLg @pholdings.
9 hours ago: "Subscriptions are available to U.S. addresses only." http://www.highlights.com another global economy #fail.
10 hours ago: "Subscriptions are available to U.S. addresses only." http://www.highlights.com another global #fail.
11 hours ago: My notes on podcast with author Aimee Bender's Lemoncake book, "a normal kid punished by expectations of giftedness": http://is.gd/eSsLg.
12 hours ago: Interesting: "one page per book": http://openlibrary.org/about.
12 hours ago: Another after-work 8K, did 5K in 23:33, getting cooler here as #berlin #marathon approaches: http://is.gd/eSp95.
yesterday: C# CODE EXAMPLE: Extension method for checking regex in one line: http://is.gd/eQzyg.
yesterday: New podcast source: "I don't want to put you to sleep, but I want to be as rich, and rewarding, and resident as a dream.":http://is.gd/eQrdC.
yesterday: An intense colin marshall interview with michael silverblatt on the art of interviewing & more: http://is.gd/eQqve (search for "blatt").
yesterday: The stackexchange site for wordpress is up: get your answers / establish your reputation @cottonr http://wordpress.stackexchange.com.
2 days ago: "I've always felt that any time you can use a tuple, you should use a struct.": http://is.gd/eQm9V.
WPF CODE EXAMPLE created on Tuesday, February 10, 2009 permalink
Example of using ObservableCollection for dependency injection
This is a test application that has in its main class an observable collection of custom objects (Tasks and News), and each time you add one of these items to the collection, it appears on the UI without any further programming. This works because the collection is bound to a XAML ItemsControl. Experiment changing the element inside the ItemsPanelTemplate e.g. from WrapPanel to StackPanel and you can see how decoupled the UI is from the data, nice. I've listed the main XAML and code behind of Window1 to look at, if you want to get it to run, download the project.
Window1.xaml:
<Window x:Class="TestObservableCollection.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Demonstration of ObservableCollection"
    Height="700"
    Width="1000"
    x:Name="mainWindow">

    <Window.Resources>

        <DataTemplate x:Key="itemsTemplate">
            <Border Width="150" Height="100" Margin="5" Padding="2" Background="#eee" >
                <Grid Width="Auto" Height="Auto">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="18"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock
                     Name="TheTitle"
                     Margin="0,0,0,0"
                     HorizontalAlignment="Left"
                        Width="150"
                     Grid.Row="0"
                     FontSize="12"
                     Foreground="#000 "
                        Padding="3,1,1,1"
                     Background="#bbb "
                     TextWrapping="Wrap"
                     Text="{Binding Title}"/>
                </Grid>
            </Border>

            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=Kind}" Value="Task">
                    <Setter TargetName="TheTitle" Property="Background" Value="Lightgreen"/>
                    <Setter TargetName="TheTitle" Property="Text" Value="{Binding Title}"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Kind}" Value="News">
                    <Setter TargetName="TheTitle" Property="Background" Value="Orange"/>
                    <Setter TargetName="TheTitle" Property="Text" Value="{Binding Kind}"/>
                </DataTrigger>
            </DataTemplate.Triggers>

        </DataTemplate>
    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
            <GradientStop Color="#ddd" Offset="0"/>
            <GradientStop Color="#777" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ItemsControl
                    Grid.Row="1"
                    Width="Auto"
                    Height="Auto"
                    Margin="5"
                    ItemsSource="{Binding ElementName=mainWindow, Path=DataItems}"
                    ItemTemplate="{StaticResource itemsTemplate}" Grid.ColumnSpan="2">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>

        <StackPanel Margin="0,0,0,0"
                Grid.Row="0" Orientation="Horizontal" Background="#888 "
                    Height="35">

            <TextBox Name="theName"
                     Width="150"
                     Height="25"
                     Margin="5 0 5 0"
                     />

            <Button Height="25"
                Content="Add Task"
                Margin="0 0 5 0"
                ToolTip="Add a task to the collection"
                Name="buttonAddTask"
                Cursor="Hand"
                />

            <Button Height="25"
                Content="Add News"
                Margin="0 0 5 0"
                ToolTip="Add a news to the collection"
                Name="buttonAddNews"
                Cursor="Hand"
                />
            <Button Height="25"
                Content="Delete latest item"
                Margin="0 0 5 0"
                ToolTip="Remove the last item from the collection"
                Name="buttonItemMinus"
                Cursor="Hand"
                />

        </StackPanel>

    </Grid>


</Window>

Window1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace TestObservableCollection
{
    public partial class Window1 : System.Windows.Window
    {
        private ObservableCollection<ApplicationItem> dataItems;

        public ObservableCollection<ApplicationItem> DataItems
        {
            get
            {
                if (dataItems == null)
                {
                    return new ObservableCollection<ApplicationItem>();
                }
                return dataItems;
            }
        }

        public Window1()
        {
            dataItems = new ObservableCollection<ApplicationItem>();

            InitializeComponent();

            buttonAddTask.Click += new RoutedEventHandler(buttonAddTask_Click);
            buttonAddNews.Click += new RoutedEventHandler(buttonAddNews_Click);
            buttonItemMinus.Click += new RoutedEventHandler(buttonItemMinus_Click);
        }

        void buttonClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
            Application.Current.Shutdown();
            e.Handled = true;
        }

        void buttonIndexMinus_Click(object sender, RoutedEventArgs e)
        {
            if (dataItems.Count >= 2)
            {
                ApplicationItem applicationItem = dataItems[1];
                applicationItem.Title = (Int32.Parse(applicationItem.Title) - 1).ToString();
            }
            e.Handled = true;
        }

        void buttonIndexPlus_Click(object sender, RoutedEventArgs e)
        {

            if (dataItems.Count >= 2)
            {
                ApplicationItem item = dataItems[1];
                item.Title = (Int32.Parse(item.Title) + 1).ToString();
            }
            e.Handled = true;
        }

        void buttonItemMinus_Click(object sender, RoutedEventArgs e)
        {
            if (dataItems.Count > 0)
            {
                dataItems.RemoveAt(dataItems.Count - 1);
            }
            if (dataItems.Count == 0)
            {
                buttonItemMinus.IsEnabled = false;
            }
            e.Handled = true;
        }

        void buttonAddTask_Click(object sender, RoutedEventArgs e)
        {
            Task item = new Task(theName.Text);
            dataItems.Add(item);
            buttonItemMinus.IsEnabled = true;
            e.Handled = true;
        }

        void buttonAddNews_Click(object sender, RoutedEventArgs e)
        {
            News item = new News(theName.Text);
            dataItems.Add(item);
            buttonItemMinus.IsEnabled = true;
            e.Handled = true;
        }
    }
}
need markup?