




Imports System

Imports System.Collections.Generic

Imports System.Linq

Imports System.Net

Imports System.Windows

Imports System.Windows.Controls

Imports System.Windows.Documents

Imports System.Windows.Input

Imports System.Windows.Media

Imports System.Windows.Media.Animation

Imports System.Windows.Shapes

Imports System.ComponentModel

Imports Telerik.Windows.Controls.GridView

Imports Telerik.Windows.Controls





Partial Public Class MainPage

    Inherits UserControl



    Public Sub New()

        InitializeComponent()

        Dim items As New List(Of Item)()


        Dim item1 As Item = New Item
        item1.Count = 1
        item1.Price = 10
        items.Add(item1)


        Me.gridView.ItemsSource = items

    End Sub



End Class



Public Class Item
    Implements INotifyPropertyChanged
    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged


    Friend Overridable Sub sendPropertyChanged(ByVal sProp As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(sProp))
    End Sub

    Public Property Name() As String

        Get

            Return m_Name

        End Get

        Set(ByVal value As String)

            m_Name = value

        End Set

    End Property

    Private m_Name As String

    Private m_price As Decimal

    Public Property Price() As Decimal

        Get

            Return Me.m_price

        End Get

        Set(ByVal value As Decimal)

            Me.m_price = value

            Recalculate()

        End Set

    End Property

    Private m_count As Integer

    Public Property Count() As Integer

        Get

            Return Me.m_count

        End Get

        Set(ByVal value As Integer)

            Me.m_count = value

            Recalculate()

        End Set

    End Property



    Private m_total As Decimal

    Public Property Total() As Decimal

        Get

            Return Me.m_total

        End Get

        Set(ByVal value As Decimal)

            Me.m_total = value

            Me.sendPropertyChanged("Total")

        End Set

    End Property



    Private Sub Recalculate()

        Me.Total = Me.Price * Me.Count

    End Sub



    Private Sub OnPropertyChanged(ByVal [property] As String)

        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs([property]))

    End Sub












End Class



