Hi,
I have a problem when binding data in a ListView.
The list view contains several columns, one column contains a
textbox. The user should be able to change the height for each item
in the listview via the text in this textbox.
Here is the code:
<DockPanel> <ListView x:Name="myListView" ItemsSource="{Binding .}"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="Height" Value="{Binding ElementName=heightTextBox, Path=Text, Converter={StaticResource myConverter}}" /> </Style> </ListView.ItemContainerStyle> <ListView.View> <GridView> <GridViewColumn Header="Text"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="Test text" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Height"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox x:Name="heightTextbox" Text="30" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> </DockPanel>
|
This example does not work, since the application fails to find the element 'heightTextbox'.
If the textbox is outside the listview everything works as intended.
How can I access the 'heightTextbox' in the ListView.ItemContainerStyle ?
I appreciate any help.
Regards,
Simon