Click here to Skip to main content
15,897,090 members
Articles / Desktop Programming / WPF

ListView, ComboBox, and ObservableCollection<T>

Rate me:
Please Sign up or sign in to vote.
4.36/5 (8 votes)
3 Feb 2010MIT5 min read 82.2K   4.9K   29  
An article on WPF data binding using ObservableCollection.
//------------------------------------------------
// BezierSegment3D.cs (c) 2007 by Charles Petzold
//------------------------------------------------
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Media3D;

namespace Petzold.Media3D
{
    public class BezierSegment3D : PathSegment3D
    {
        /// <summary>
        ///     Identifies the Point1 dependency property.
        /// </summary>
        public static readonly DependencyProperty Point1Property = 
            DependencyProperty.Register("Point1", 
            typeof(Point3D),
            typeof(BezierSegment3D),
            new PropertyMetadata(new Point3D()));

        /// <summary>
        ///     Gets or sets the first control point of the curve. 
        /// </summary>
        public Point3D Point1
        {
            set { SetValue(Point1Property, value); }
            get { return (Point3D) GetValue(Point1Property); }
        }

        /// <summary>
        ///     Identifies the Point2 dependency property. 
        /// </summary>
        public static readonly DependencyProperty Point2Property =
            DependencyProperty.Register("Point2", 
            typeof(Point3D),
            typeof(BezierSegment3D),
            new PropertyMetadata(new Point3D()));

        /// <summary>
        ///     Gets or sets the second control point of the curve. 
        /// </summary>
        public Point3D Point2
        {
            set { SetValue(Point2Property, value); }
            get { return (Point3D)GetValue(Point2Property); }
        }

        /// <summary>
        ///     Identifies the Point3 dependency property. 
        /// </summary>
        public static readonly DependencyProperty Point3Property =
            DependencyProperty.Register("Point3", 
            typeof(Point3D),
            typeof(BezierSegment3D),
            new PropertyMetadata(new Point3D()));

        /// <summary>
        ///     Gets or sets the final point of the curve. 
        /// </summary>
        public Point3D Point3
        {
            set { SetValue(Point3Property, value); }
            get { return (Point3D)GetValue(Point3Property); }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return String.Format("C{0} {1} {2}", Point1, Point2, Point3);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override Freezable CreateInstanceCore()
        {
            return new BezierSegment3D();
        }
    }
}

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 MIT License


Written By
Technical Lead Rockwell Automation
Singapore Singapore
He is a Software Engineer at Rockwell Automation Asia Pacific Business Center, working on RSLogix 5000. Prior to joining Rockwell Automation, he had worked for Sybase for 8 years and was the original architect of the PowerBuilder Native Interface and the PowerBuilder .NET Compiler that can compile PowerBuilder applications to .NET Windows Forms or Web Forms applications. The programming languages he has used or is using intensively include C#, C++, C and 8086 assembly.

Wu XueSong's Blog

Comments and Discussions