So i have this issue:
- I have created a UserControl (basically a textbox and label). This user control I am able to Bind using a Dependency Property.
- I have a ListView in which I can put a textbox in the datatemplate and bind the "text" property to the binded value.
so far so good. but now if I try to put the UserControl into that very same scenario the DependencyProperty stops working.
Here is the code: [ListView]
<ListView x:Name="DtContactDetailListView" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<UserControl:tbx label="{Binding detail}" text="{Binding value}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListView>
The binding in this situation works when its outside the listview, in other parts of the form... so its not an issue with my DepedencyProperty. Also substituting the UserControl for a Textbox, and adding the exact same Binding also works. But it doesn't work under this... why?!
UPDATE As requested, I have updated the code for the UserControl. Keep in mind this works perfectly when binding it to other elements on the window or page. Just doesn't work inside a listview.
Public Sub New()
InitializeComponent()
Me.DataContext = Me
End Sub
'TextBox property
Public Shared ReadOnly tbxTextProperty As DependencyProperty = DependencyProperty.Register("text", GetType([String]), GetType(tbx), New FrameworkPropertyMetadata(String.Empty))
Public Property text() As [String]
Get
Return GetValue(tbxTextProperty).ToString()
End Get
Set(value As [String])
SetValue(tbxTextProperty, value)
End Set
End Property
UserControl:tbx? Maybetbx:UserControl? - Hamlet Hakobyan