我正在开发Windows Phone 8应用程序。我需要在我的应用程序的某些部分的用户响应 我创建Windows Phone用户控制页面。用户将从列表框中选择一个值在用户控件页如何获取列表框中选择的项目标签在主页xaml
这里是我的用户控制网页
<Grid x:Name="columngrid" Background="#FF1FCB4E" Width="480" >
<Grid.RowDefinitions>
<RowDefinition Height="300"/>
<RowDefinition Height="70"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<ListBox Name="URLListBox" Grid.Row="0" Background="#FF1FCB4E" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF0B232F" BorderThickness="2">
<TextBlock x:Name="surename" Width="460" Tag="{Binding b1Tag}" Height="80" FontSize="25" Text="{Binding text}" Foreground="#FFBF9595" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0" />
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="1" x:Name="btnOK" Content="OK" Background="#FF892121" />
<Button Grid.Row="2" x:Name="btnCancel" Content="Cancel" Background="#FF892121"/>
</Grid>
的代码,我想选择的文本块的文本mainpage.xaml.But当我在用户控制网页我不能达到文本块创建类的对象。我只能到达listbox.How我可以得到选定的文本块的文本 我试试这个,但我意识到旨意带来ListBox对象
surah popupsurah = new surah();//usercontrol page
Popup popup2 = new Popup();
private void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
collapsedgrid.Visibility = Visibility.Collapsed;
popupsurah.URLListBox.Tap += (s, args) =>
{
string transferID = ((TextBlock)s).Text as string;
这里是一个示例帮助你出http://www.geekchamp.com/tips/how-to-expose-properties-of-a-user-control-in-windows-phone –