Click here to Skip to main content
15,881,089 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: New to .net/ previous programming background Pin
Alisaunder3-Oct-12 17:10
Alisaunder3-Oct-12 17:10 
AnswerRe: New to .net/ previous programming background Pin
_Maxxx_7-Oct-12 17:17
professional_Maxxx_7-Oct-12 17:17 
QuestionJesús Alvarez Manrique Pin
Member 901299827-Sep-12 6:47
Member 901299827-Sep-12 6:47 
AnswerRe: Jesús Alvarez Manrique Pin
Yayozama27-Sep-12 7:37
Yayozama27-Sep-12 7:37 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 7:57
Member 901299827-Sep-12 7:57 
GeneralRe: Jesús Alvarez Manrique Pin
Emmanuel Medina27-Sep-12 11:33
professionalEmmanuel Medina27-Sep-12 11:33 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 7:59
Member 901299827-Sep-12 7:59 
QuestionBobbles in paradise - ViewModel and my personal adventures in WTF Pin
Kenneth Haugland26-Sep-12 18:25
mvaKenneth Haugland26-Sep-12 18:25 
Sorry about the heading, but I really couldnt resist. The question is realted to arcitecture of the implementation of ViewModels in WPF, and its based on the application a wrote an article about here[^], and the code that Im wondering about changing to, hopefully, something better is this:

I have a MainViewModel class where I initiate a Property of ObservableCollections, that contains elements of this class:
VB
Public Class RadioButtonProperies

        Private _Text As String
        Public Property Text() As String
            Get
                Return _Text
            End Get
            Set(ByVal value As String)
                _Text = value
            End Set
        End Property

        Private _Index As Integer
        Public Property Index() As Integer
            Get
                Return _Index
            End Get
            Set(ByVal value As Integer)
                _Index = value
            End Set
        End Property

        Private _IsChecked As Boolean = False
        Public Property IsChecked() As Boolean
            Get
                Return _IsChecked
            End Get
            Set(ByVal value As Boolean)
                _IsChecked = value
                If value Then
                    SelectionIndexChanged(Index)
                End If
            End Set
        End Property

        Public Event SelectionIndexUpdated(ByVal index As Integer)

        Private Sub SelectionIndexChanged(ByVal index As Integer)
            RaiseEvent SelectionIndexUpdated(index)
        End Sub

    End Class


As you can see, I Raise an event when the IsChecked property is set to true, and this event is also raised and passed on from the MAinViewModel class, so I can react if you changed the RadioButton selection on the MainWindow:
VB
'Store a pointer to a ViewModel cthat contains all the RadioButtons
Private _Intersections As MainViewModel

Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

    'Get all the radiobuttons, and add a handler to Selection changed
    _Intersections = DirectCast(rbtn.DataContext, MainViewModel)
    AddHandler _Intersections.SelectionIndexUpdated, AddressOf rbtnSelectionChanged
End Sub


Public Sub rbtnSelectionChanged(ByVal Value As Integer)
    'Sets the enum of selection on the child control
    DrawingControl.DrawingCanvas.CanvasEvent = Value
End Sub


My question is this: theres got to be a more effective way of doing this, as my implementation is really cumbersome, and the more I look at it the more ridiculose it seems, and the more i dislike it.

What are the guidelines for implementing functionallity like this? Are there any other ways whitch is easyer or better? Any thoughts?

Regards

Kenneth
Questionbeginner : binding ListBox Pin
dominioYP26-Sep-12 4:05
dominioYP26-Sep-12 4:05 
AnswerRe: beginner : binding ListBox Pin
Pete O'Hanlon26-Sep-12 4:26
mvePete O'Hanlon26-Sep-12 4:26 
GeneralRe: beginner : binding ListBox Pin
dominioYP26-Sep-12 5:41
dominioYP26-Sep-12 5:41 
GeneralRe: beginner : binding ListBox Pin
dominioYP28-Sep-12 5:38
dominioYP28-Sep-12 5:38 
Questionbeginner : listView, add scrollBar Pin
dominioYP26-Sep-12 3:50
dominioYP26-Sep-12 3:50 
QuestionTrying to set focus on DataGrid with DataGridTemplateColumn Pin
abollmeyer23-Sep-12 3:44
abollmeyer23-Sep-12 3:44 
AnswerRe: Trying to set focus on DataGrid with DataGridTemplateColumn Pin
abollmeyer24-Sep-12 14:13
abollmeyer24-Sep-12 14:13 
QuestionOn ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 3:46
mvaKenneth Haugland21-Sep-12 3:46 
AnswerRe: On ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 13:42
mvaKenneth Haugland21-Sep-12 13:42 
QuestionWPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 11:30
professionalKevin Marois20-Sep-12 11:30 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 11:47
mvaKenneth Haugland20-Sep-12 11:47 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 11:59
mvePete O'Hanlon20-Sep-12 11:59 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 12:10
mvaKenneth Haugland20-Sep-12 12:10 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 12:01
mvePete O'Hanlon20-Sep-12 12:01 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 13:23
professionalKevin Marois20-Sep-12 13:23 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 13:58
mvePete O'Hanlon20-Sep-12 13:58 
Questionstackedbarseries chart: change the axes display Pin
ashlyacht19-Sep-12 10:03
ashlyacht19-Sep-12 10:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.