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,712 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Here is code for WPF window (omitting irrelevant stuff):
XAML
<ListBox
x:Name="lbxEvents">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox
BorderThickness="0"
FontWeight="SemiBold"
Padding="0,2,0,2"
Text="{Binding Path=Title, Mode=OneWay}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Code behind:
Public Sub New()
InitializeComponent()
DataContext = Me
End Sub
Public Structure evt
Public Beginning As Date
Public CategoryID As Integer
Public Title As String
End Structure
Private Sub PopulateUpcomingEvents()
Dim ev As evt
Dim evts As New List(Of evt)
<<Events are populated correctly>>
lbxEvents.ItemsSource = evts
End Sub
Error message:
System.Windows.Data Error: 40 : BindingExpression path error: 'Title' property not found on 'object' ''evt' (HashCode=-13885767)'. BindingExpression:Path=Title; DataItem='evt' (HashCode=-13885767); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')
I cannot see why this error occurs.