I have a ListBox where I add custom objects, when the user clicks these custom objects in that ListBox some WPF Controls are generated in a stackpanel, these WPF Controls are properties of the custom objects. Below you may see the class.
<pre> Public Class VariableClass
Public Property Content As String
Public Property myNameLabel As New Label
Public Property myNameTextBox As New ComboBox
Public Property myTypeLabel As New Label
Public Property myTypeTextBox As New ComboBox
Public Overrides Function ToString() As String
I want to know what PropertyName the control the user types into has.
<pre> Private Sub ValuePanel_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles ValuePanel.PreviewKeyDown
Dim myElement As ComboBox = e.OriginalSource.TemplatedParent
Dim myVar = GetValue(myElement).GetType().GetProperty("PropertyName")
However myElement is not a DependencyObject and cannot be cast to one, I don't know how else to get the PropertyName or the VariableName.