【发布时间】:2015-04-14 12:17:21
【问题描述】:
我一直在尝试从文本框集合中获取文本,这些文本框是通过使用项目控件将集合绑定到堆栈面板来动态创建的,该控件位于单独的用户控件中,我正在 Windows Phone 运行时的页面上加载该控件。
下面是我的 UserControl 的代码:
<UserControl
x:Class="CfMobility.UserControls.CredentialsUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CfMobility.UserControls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding SelectedCategorySettings}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel IsTapEnabled="False">
<TextBlock Text="{Binding SettingKey}" Style="{ThemeResource BaseTextBlockStyle}"></TextBlock>
<TextBox Text="{Binding SettingValue}" Width="300px"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</UserControl>
我在另一个页面中有一个内容控件,如下所示:
<ContentControl x:Name="Container" Grid.Row="1" Margin="19,10,19,0">
</ContentControl>
当我导航到页面时,我将此内容控件绑定到上面的堆栈面板。
如您所见,我已使用 ItemsScroll 将“SelectedCategorySettings”集合绑定到 StackPanel,它根据集合显示文本框的数量。在这里我无法弄清楚是否要将页面上显示的所有文本框中的文本保存到 json 文件中,如何访问在上述场景中动态显示的所有文本框的文本?
PS:注意items是控件在单独的用户控件中。
提前致谢
【问题讨论】:
标签: windows-phone windows-phone-8.1 winrt-xaml