Making WebBrowser Transparent

前端 未结 4 1070
走了就别回头了
走了就别回头了 2020-12-07 02:36

I am trying to make a WebBrowser control on my Windows 7 Phone app transparent, so it can have the same theme as the rest of the app, but I have had no success with anything

4条回答
  •  时光说笑
    2020-12-07 03:29

    Code-solution:

    private void SetHtml(WebBrowser browser, string body)
    {
        string style = "";
        string html = "" + style + "" + body + "";
    
        Color phoneBackground = (Color)Application.Current.Resources["PhoneBackgroundColor"];
        browser.Background = new SolidColorBrush(phoneBackground);
        browser.Opacity = 0;
        browser.NavigateToString(html);
        browser.LoadCompleted += browser_LoadCompleted;
    
    
    }
    
    void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
    {
        _browser.OpacityMask = null;
        _browser.Opacity = 1;
    }
    

提交回复
热议问题