Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3949768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:31:57+00:00 2026-05-20T01:31:57+00:00

I used a those article to create AttachedProperty of Webbrowser control, so I can

  • 0

I used a those article to create AttachedProperty of Webbrowser control, so I can bind the “BindableSource” to my public property “Path”. It is great and work well with one small disadvantage.
In my ViewModel constructor the property is set to:

Path = new Uri("http://microsoft.com");

When the page is loaded I navigate to another link and “WebBrowser.Source” property is changed but “WebBrowser.BindableSource” is not changed.
When I click a button which set again:

 Path = new Uri("http://microsoft.com");

The “BindableSourcePropertyChanged” is not called because the property has those value.

I had an idea how to solve it but its not good, because slow the performance, It is to set Path to another URL and after that set it to real URL (http://microsoft.com).

   Path = new Uri("http://google.com");
   Path = new Uri("http://microsoft.com");

Can you give me please a better idea, how can I solved it.
Thanks in advanced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:31:57+00:00Added an answer on May 20, 2026 at 1:31 am

    I propose to synchronize BindableSource with Navigated event.
    You coukld achieve this by exposing another one attached behaviour at your WebBrowserUtility class, that reacts on Navigated event like this:

        public static readonly DependencyProperty ShouldHandleNavigatedProperty =
            DependencyProperty.RegisterAttached(
                "ShouldHandleNavigated", 
                typeof(Boolean), 
                typeof(WebBrowserUtility), 
                new UIPropertyMetadata(false, ShouldHandleNavigatedPropertyChanged));
    
        public static Boolean GetShouldHandleNavigated(DependencyObject obj)
        {
            return (Boolean)obj.GetValue(BindableSourceProperty);
        }
    
        public static void SetShouldHandleNavigated(DependencyObject obj, Boolean value)
        {
            obj.SetValue(ShouldHandleNavigatedProperty, value);
        }
    
        public static void ShouldHandleNavigatedPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            WebBrowser browser = o as WebBrowser;
            if (browser != null)
            {
                if ((bool)e.NewValue)
                {
                    browser.Navigated += new NavigatedEventHandler(Browser_Navigated);
                }
                else
                {
                    browser.Navigated -= new NavigatedEventHandler(Browser_Navigated);
                }
            }
        }
    
        private static void Browser_Navigated(object sender, NavigationEventArgs e)
        {
            WebBrowser browser = sender as WebBrowser;
            if (browser != null)
            {
                browser.SetValue(WebBrowserUtility.BindableSourceProperty, browser.Source.AbsoluteUri);
            }
        }
    

    Usage in xaml:

    <WebBrowser self:WebBrowserUtility.BindableSource="{Binding WebAddress}"
                self:WebBrowserUtility.ShouldHandleNavigated="True"/>  
    

    P.S. I should admit that this implementation is rather dirty, because setting of BindableSource inside Navigated event handler forces one additional event fireing. But this code works, and you could consider about its improvement.

    EDITED

        public static class WebBrowserUtility
        {
            ...
            private const string _SkipSourceChange = "Skip";
    
            public static void BindableSourcePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
            {
                WebBrowser browser = o as WebBrowser;
                if (browser != null)
                {
                    string uri = e.NewValue as string;
                    if (!_SkipSourceChange.Equals(browser.Tag))
                    {
                        browser.Source = uri != null ? new Uri(uri) : null;
                    }
                }
            }
    
            private static void Browser_Navigated(object sender, NavigationEventArgs e)
            {
                WebBrowser browser = sender as WebBrowser;
                if (browser != null)
                {
                    if (WebBrowserUtility.GetBindableSource(browser) != e.Uri.ToString())
                    {
                            browser.Tag = _SkipSourceChange;
                            browser.SetValue(WebBrowserUtility.BindableSourceProperty, browser.Source.AbsoluteUri);
                            browser.Tag = null;
                    }
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For those of you who have ever used Microsoft Excel in a manner that
i used java reflections to get methods from a class(loaded those classes).Now i want
A little help from those who’ve used Timthumb before. http://themes.amplus.gambit.ph/wp-content/themes/amplus/functions/timthumb.php?src=http://themes.amplus.gambit.ph/wp-content/uploads/2011/02/12979795614923485443_a1967ff888_b.jpg&w=860&h=300&f=5,255,0,0,0 This image should be
All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those
I'm learning C++ and came across those *.lib files that are obviously used by
I used schemaExport to create my tables like this Configuration config = new Configuration();
I used this article to write my first own Powershell Cmdlet and Snapin. And
I've used the sql from this article https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/datacenter/?p=275 to try and track down the
I see these terms used interchangeably as the global environment for the DOM. What
I have heard both of these terms used, are they the same thing or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.