简体   繁体   中英

Get selected controls from Pivot.ItemTemplate

I have a XAML:

<phone:Pivot  Name="pivot" SelectionChanged="pivot_SelectionChanged">            
              <phone:Pivot.ItemTemplate>
                <DataTemplate>                        
                            <ViewportControl Name="viewport">
                            <Canvas Name="canvas">
                                <Image Name="image"  
                                        RenderTransformOrigin="0,0" 
                                        CacheMode="BitmapCache"

                                        Source="{Binding ImageSource}">
                                        <Image.RenderTransform>
                                            <ScaleTransform x:Name="xform"/>
                                        </Image.RenderTransform>
                                </Image>
                            </Canvas>
                        </ViewportControl>
                    </DataTemplate>
                </phone:Pivot.ItemTemplate>
            </phone:Pivot>  

Can I get current ViewportControl, Canvas, etc for selected item? For example

private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //get ViewportControl, Canvas, etc           
        } 

Not necessarily with SelectionChanged , may have other solutions?

Yes, but you have to search for them. You need to use VisualTreeHelper and hunt for children of the desired type.

Or you can have some mapping in the code-behind for all controls and the parent pivot items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM