Isusse in textbox.text binfing with object property

Ajeje Brazorf 106 Reputation points

I've a classe Game with a string property Name.

 Public Class Game  
        Private _Name As String  
        Public Property Name As String  
                Return _Name  
            End Get  
            Set(ByVal value As String)  
                _Name = value  
            End Set  
        End Property  
    End Class  

in my viewmodel I declared
Public Property Newcompetition As New Game

In the view:

<TextBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="6" HorizontalContentAlignment="Right"  FontSize="16" FontWeight="Bold" FontFamily="Bahnschrift SemiBold" >  
                <Binding Path="Name" Source="Newcompetition"  
                   UpdateSourceTrigger="PropertyChanged" Mode="Two Way"/>  

I also placed a button, to debug purpose , with show a messagebox with newcompetition.Name value.

But binding seem not working, I still get exception that Newcompetition is empty.
Any Advice?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,667 questions
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,565 questions
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ajeje Brazorf 106 Reputation points

    I finally solved:
    as Viorel-1 adive I removed the space: Mode="TwoWay", and in xaml:

                     <Binding Path="NewCompetition.Name"  
                        UpdateSourceTrigger="PropertyChanged" Mode="Two Way"/>  

    I don't understand way using source and path tags it not worked, but in this way it seem to work.

    0 comments No comments