WPF Browser is there, but invisible

前端 未结 6 974
面向向阳花
面向向阳花 2021-02-13 05:07

I am attempting to use the Browser control in a very simple WPF application, and it appears that while the browser is loading the page that I requested (I can mouseover images a

6条回答
  •  孤街浪徒
    2021-02-13 05:14

    Are you setting the WebBrowser.Source property? I tried the following XAML in Kaxaml and it worked fine:

        
            
                
                    
                        
                        
                        
                    
                    
                        
                        
                    
                    
                    
                    
                    
                
            
        
    

    As for general XAML newbie tips:

    • Avoid using Height and Width and instead learn how the layout controls work (DockPanel, StackPanel, Grid, etc). If you really want to enforce something's size, consider whether using MinWidth and MinHeight would achieve what you wanted better.
    • Most controls have transparent backgrounds by default, so you don't need to put that in your XAML.
    • I tend to favour TextBlock over Label for pieces of text on screen. Your mileage may vary, but most examples use TextBlock in my experience.

    EDIT

    I put together an alternative layout for you that avoid the use of Grid:

        
            
                
                    
                    
                        
                        
                    
                    
                
            
        
    

    You may want to go through and update the margins to have it look as you want it to.

    Also, from your screenshot it's clear that you have some additional styles/templates playing a role here as the XAML doesn't match what's seen in the image. Perhaps values coming from those styles are messing with your control.

提交回复
热议问题