我知道類似這樣的問題已經在SO中問了好幾次了。但他們中沒有人能夠解決我的問題,並且在理解這些答案時遇到了一些困難這是我的情況;我有一個ItemsControl
我已經使用ItemTemplate
並綁定了一些數據。訪問DataTemplate中的文本框
<Window.Resources>
<DataTemplate x:Key="AdditionalFieldTemlate">
<Grid>
<TextBlock Text="{Binding InfoName}"/>
<TextBox Text="{Binding InfoValue,Mode=TwoWay}" Name="CustomValue"/>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<ItemsControl ItemsSource="{Binding AdditionalInformation}" x:Name="additionalInfo" ItemTemplate="{DynamicResource AdditionalFieldTemlate}"/>
</Grid>
我需要設置TextBox
文本爲空(裏面的DataTemplate所有文本框的文本),一旦點擊一個Button
。不知道如何訪問這些文本框。請幫幫我。