Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / Visual Basic 10

Generic Multi-Select MVVM ListBox Drag and Drop Helper with Custom Feedback for Silverlight 4.0

Rate me:
Please Sign up or sign in to vote.
4.91/5 (3 votes)
11 Apr 2011CPOL9 min read 53.3K   981   13  
This article focuses on developing an MVVM compatible ListBox-to-ListBox drag/drop helper for Silverlight.
'/* Copyright (c) 2011, Graeme Grant (gragra33@hotmail.com)
' * All rights reserved.
' *
' * Redistribution and use in source and binary forms, with or without
' * modification, are permitted provided that the following conditions are met:
' *
' *   * Redistributions of source code must retain the above copyright
' *     notice, this list of conditions and the following disclaimer.
' * 
' *   * Redistributions in binary form must reproduce the above copyright
' *     notice, this list of conditions and the following disclaimer in the
' *     documentation and/or other materials provided with the distribution.
' * 
' * THIS SOFTWARE IS PROVIDED BY GRAEME GRANT ``AS IS'' AND ANY
' * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
' * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' * DISCLAIMED. IN NO EVENT SHALL GRAEME GRANT BE LIABLE FOR ANY
' * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
' * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
' * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
' * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
' * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
' */

Imports Helpers

Public Class TagModel : Inherits ModelBase

#Region "Constructor"

    Sub New()
        '
    End Sub

#End Region

#Region "Properties"

    Public Const TagPropertyName As String = "Tag"

    Private _Tag As String
    Public Property Tag() As String
        Get
            Return _Tag
        End Get
        Set(ByVal value As String)
            If _Tag = value Then
                Return
            End If
            _Tag = value
            RaisePropertyChanged(TagPropertyName)
        End Set
    End Property

    Public Const NamePropertyName As String = "name"

    Private _Name As String
    Public Property name() As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            If _Name = value Then
                Return
            End If
            _Name = value
            RaisePropertyChanged(NamePropertyName)
        End Set
    End Property

    Public Const num_productsPropertyName As String = "num_products"

    Private _num_products As Integer
    Public Property num_products() As Integer
        Get
            Return _num_Products
        End Get
        Set(ByVal value As Integer)
            If _num_Products = value Then
                Return
            End If
            _num_Products = value
            RaisePropertyChanged(num_ProductsPropertyName)
        End Set
    End Property

    Public Const weightPropertyName As String = "weight"

    Private _weight As Integer
    Public Property weight() As Integer
        Get
            Return _weight
        End Get
        Set(ByVal value As Integer)
            If _weight = value Then
                Return
            End If
            _weight = value
            RaisePropertyChanged(weightPropertyName)
        End Set
    End Property

#End Region

    Public Overrides Function ToString() As String
        Return String.Format("Tag: {0} / Products: {1}", Tag, num_Products)
    End Function

    Public Sub SetData(Data As TagModel)

        With Data
            Tag = .Tag
            name = .name
            num_Products = .num_Products
            weight = .weight
        End With

    End Sub

End Class

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 Code Project Open License (CPOL)


Written By
Technical Lead
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions