Click here to Skip to main content
16,015,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can I bind the Text of Label to property Summ ?


VB.NET
Public Class SummClass
    Implements INotifyPropertyChanged
    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    Private _Summ As Integer
    Public Property Summ As Integer
        Get
            Return _Summ
        End Get
        Set(value As Integer)
            _Summ = value
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(NameOf(Summ)))
        End Set
    End Property
End Class


VB.NET
Public Class ReportClass
    Public Property Month As Integer
    Public Property Summary As New ObservableCollection(Of SummClass)
End Class


VB.NET
Public Property MyReport As New ReportClass


What I have tried:

VB.NET
Dim binding As New Binding()
    binding.Path = New PropertyPath(MyReport.Summary(i).Summ)
    binding.RelativeSource = New RelativeSource(RelativeSourceMode.FindAncestor, GetType(Window), 1)
    binding.Mode = BindingMode.TwoWay
    binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged

    LabelSumMamooriat.SetBinding(Label.ContentProperty, binding)


'i' is a number between 0 to 4 which user set. Because this company has 5 employees.
Posted
Updated 15-Aug-24 0:18am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900