Panorama to Hub considerations
Panorama control ( https://msdn.microsoft.com/en-us/library/windows/apps/ff941104.aspx ) acts as a container control. For example:
<controls:Panorama> ... <controls:PanoramaItem> <TextBlock x:Name="myText" /> </controls:PanoramaItem> ... </control:Panorama>
The recommended control (https://msdn.microsoft.com/en-us/library/mt149137.aspx ) for converting the Panorama control to UWP is the
Hub control (https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.hub.aspx ).
The current conversion of this control is the following:
<Hub> ... <HubSection> <DataTemplate> <TextBlock x:Name="myText" /> </DataTemplate> </HubSection> ... </Hub>
However this control behaves differently from Panorama in the way it treats the child elements of
HubSections uses a
DataTemplate which doesn't allow to use names x:Name to make child element accessible to code behind or animation targets.
There are several ways to solve this problem:
- Define a field for the control and assign it using the control's Loaded event (described here: http://stackoverflow.com/questions/22659179/how-to-access-controls-within-hubsections-in-win-8-1-store-app-searching-in-vis )
- Avoid using the controls directly on code behind and use an MVVM approach by binding the required properties to a view model.
- Animation targets still require named elements
More information here