Answer the question
In order to leave comments, you need to log in
How to access dynamically created objects using datatemplate in xaml?
ReportParameter class
public class ReportParameter
{
public string ColumnName { get; set; }
public string ParameterType { get; set; }
}
ParameterList.Add(new ReportParameter() { ColumnName = param.ColumnName, ParameterValue = param.ParamValue });
<ListView ItemsSource="{Binding ParameterList}">
<ListView.Resources>
<DataTemplate DataType="{x:Type generic:ReportParameter}">
<StackPanel>
<Label Content="{Binding Path=ColumnName}" />
<TextBox Text="{Binding Path=ParameterValue}" />
</StackPanel>
</DataTemplate>
</ListView.Resources>
</ListView>
private string _propety;
public string Property
{
get { return _propety; }
set
{
if (value == _propety) return;
_propety = value;
OnPropertyChanged("Property");
}
}
Answer the question
In order to leave comments, you need to log in
No need to access TextBoxes, this violates the MVVM principle (although it is possible through hacks like visual tree traversal). Moreover, in the mode
VirtualizingStackPanel.VirtualizationMode="Recycling"
(which is used by default) not all elements of the ParameterList array will correspond to TextBoxes.Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question