Access to list picker inside PanoramaHeader template

I have a pan control in which I created a header template to add a list picker to it. (Just like the center of people selects 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>

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

I do not know how to do that. I tried adding the x: name property to the list, I do not have access to it in the MainPage code.

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

0
source share
3

, , , , -

. :

DataTemplate?

+1

ListPicker x: Name, : PanoramaItem ListPicker. , : , ? , , (ItemSource)

0

, :

<Grid Name="myGrid">
<StackPanel x:Name="stack1">
<TextBlock x:Name="abc"/>
</StackPanel>
</Grid>

Grid myGrid . StackPanel, :

StackPanel myStack=myGrid.FindName("stack1") as Stackpanel;

TextBlock:

TextBlock myTextBlock=myStack.FindName("abc") as TextBlock;

You can change myTextBlock after that as you like. You can apply the same technique in your case, and it will work. Hope this helps :).

0
source

Source: https://habr.com/ru/post/1782055/


All Articles