locked
Deferred Loading in XAML - GetTemplateChild doesn't realize element RRS feed

  • Question

  • Hello!

    I am trying all features of DeferLoadStrategy. Here is article about it

    As I have understand from there I can realize element with:

    Call GetTemplateChild with the name that was defined on the element.

    But when I try this - it is doesn't realized.

    When I try FindName - everything is ok. What is wrong? Can someone also try this?


    Tuesday, September 15, 2015 11:41 AM

Answers

  • @Sommer,

    I'll try report this issue to see whether it is our problem or the API problem. But it seems it need some time for a response.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 17, 2015 3:32 AM

All replies


  • Hello Sommer,

     

    >>Have you reproduced this issue?

    I can reproduce this with a single button,like:

     

    private void button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    
            { 
    
               this.FindName("button2");
    
            }
    

    In button1 click event I use FindName and it works well. But if I change to use GetTemplateChild it does not work even when I use OnApplyTemplate.

     

    private void button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    
            {
    
                
    
                //this.FindName("button2"); 
    
                ApplyTemplate(); 
    
            } 
    
     
    
     
    
            public void ApplyTemplate() 
    
            {
    
                this.OnApplyTemplate(); 
    
            }
    
     
    
            protected override void OnApplyTemplate() 
    
            {
    
               GetTemplateChild("test");
    
            }
    

     

    It seems GetTemplateChild always return null. Can you confirm with me about this?

     

    Best regards,

    Barry



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Barry Wang Wednesday, September 16, 2015 8:36 AM
    Wednesday, September 16, 2015 8:34 AM
  • Yes, I can confirm that when I try your code it also doesn't work - GetTemplateChild returns null.

    I have even tried to use custom control template.

    But if to use FindName everything works well.


    Wednesday, September 16, 2015 1:34 PM
  • @Sommer,

    I'll try report this issue to see whether it is our problem or the API problem. But it seems it need some time for a response.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 17, 2015 3:32 AM