locked
Access Frame Control - contained within DataTemplate of HubSection RRS feed

  • General discussion

  • I am writing to learn how best a Frame element, defined within the DataTemplate of a HubSection, can be programmatically accessed from C# - for an upcoming Windows 8.1 project; 

    The new Hub App template is being utilized, with Xaml and C# contained in the below snippets - the code of "return this.FrameContent" is not recognized;

    Thanks in advance for insight, guidance;

     <HubSection Width="520" x:Uid="Section2Header" Header="Section 2" Loaded="HubSection_Loaded">
    
                    <DataTemplate x:Name="PodDataTemplate">
                        <Frame x:Name="FrameContent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    </DataTemplate>
                    
                </HubSection>

    public Frame GetFrameContent()
            {
                return this.FrameContent;
            }


    robert hellestrae

    Tuesday, October 8, 2013 5:15 PM

All replies

  • x:Name'd elements aren't findable in this manner in DataTemplates.  If this is critical to your scenario, instead of putting the content directly in the hub section you could put it in a usercontrol and put that UC in the hub section.

    Tim Heuer | Program Manager, UI Platforms (XAML, WinJS) | http://timheuer.com/blog | @timheuer | Callisto - XAML UI Toolkit

    (if my post has answered your question, please consider using the *mark as answer* feature in the forums to help others)

    Wednesday, October 9, 2013 3:53 PM
  • Thanks Tim;

    Can a code sample be provided to access the Frame, and/or User Control from C#;

    Utilizing the below Xaml code, I am not able to reference the Frame, User Control from C#;

    Thanks in advance for insight, guidance;

     <HubSection Width="500" x:Uid="Section1Header" Header="Section 1">
                    <DataTemplate>
                        <UserControl x:Name="ucTest">
                            <Frame x:Name="frmTest" ></Frame>                        
                        </UserControl>
                    </DataTemplate>
                </HubSection>


    robert hellestrae

    Wednesday, October 9, 2013 4:47 PM
  • It wouldn't be literally how you have it but rather you'd have a file foo.xaml that contained your Frame and then in the page that has the hub:

    <HubSection>
      <DataTemplate>
        <local:MyUserControl />

    Now in your user control you'd have to write some code to get at whatever objects you need and perform the tasks.


    Tim Heuer | Program Manager, UI Platforms (XAML, WinJS) | http://timheuer.com/blog | @timheuer | Callisto - XAML UI Toolkit

    (if my post has answered your question, please consider using the *mark as answer* feature in the forums to help others)

    Wednesday, October 9, 2013 4:56 PM