Load a Page into a ContentControl

后端 未结 1 1881
[愿得一人]
[愿得一人] 2021-01-16 17:32

I have a ContentControl where I want to load the page myPage2. My XAML Codefrom this page looks like this:



        
1条回答
  •  甜味超标
    2021-01-16 17:58

    There is no reason to use a Page within a ContentControl. A Page is a subclass of the UserControl class that adds support for being used within a Frame control to support navigation, back stack/history, etc. You should probably replace Page with UserControl in XAML and code behind, so you would end up with something like this:

    
        
            ...
            ...
        
    
    

    You can put the UserControl itself in a DataTemplate if you want to use it as a DataTemplate in a ContentControl:

    
        
            
                
            
        
    
    

    0 讨论(0)
提交回复
热议问题