访问PanoramaHeader模板中的列表选择器 [英] Accessing a list picker inside a PanoramaHeader Template

查看:79
本文介绍了访问PanoramaHeader模板中的列表选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全景控件,在其中创建了一个标题模板,以便在其中添加列表选择器. (就像选择人脉的人民枢纽一样)

I have a panorama control in which I have create a header template to add a list picker inside it. (Just like the peoples hub to select social accounts)

<DataTemplate x:Key="PanoramaItemHeaderTemplate">
     <ContentPresenter>
          <StackPanel Height="129">
               <TextBlock Text="{Binding}" FontSize="72" Margin="0,7,0,0" />
               <toolkit:ListPicker x:Name="listPick" Margin="0,-21,0,0" BorderThickness="0">
                     <toolkit:ListPickerItem Content="twitter"></toolkit:ListPickerItem>
               </toolkit:ListPicker>                    
          </StackPanel>
     </ContentPresenter>
</DataTemplate>

全景控件位于MainPage.xaml文件中,我希望可以从后面的代码访问listpicker,以便能够填充它并处理选择事件.

The panorama control is inside the MainPage.xaml file and I want to have access to the listpicker from the code behind to be able to populate it, and handle it selection events.

我不知道该怎么做.我尝试将x:name属性添加到列表选择器中,但在后面的MainPage代码中无法访问它.

I don't know how to do this. I tried adding the x:name property to the list picker I don't have access to it in the MainPage code behind.

非常欢迎您提出任何解决方法的想法,谢谢!

Any idea on how to approach this is very welcomed, thanks!

推荐答案

从现在开始,最快的方法是遍历视觉树

From what you have now, the quickest way to do what you want is to traverse the visual tree

有关实现,请参见此处:

See here for the implementation:

如何在带有DataTemplate的列表框?

这篇关于访问PanoramaHeader模板中的列表选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆