コード例 #1
0
        public static void BindableSourcePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            WebBrowser browser = o as WebBrowser;

            if (browser == null)
            {
                return;
            }

            Uri uri = null;

            var s = e.NewValue as string;

            if (s != null)
            {
                var uriString         = s;
                var bindingExpression = browser.GetBindingExpression(BindableSourceProperty);
                if (bindingExpression != null)
                {
                    var binding = bindingExpression.ParentBinding;
                    uri = string.IsNullOrWhiteSpace(uriString) ? null : new Uri(string.Format(binding.StringFormat, uriString));
                }
            }
            else if (e.NewValue is Uri)
            {
                uri = (Uri)e.NewValue;
            }

            browser.Source = uri;
        }
コード例 #2
0
        private static BindingExpression GetAndAssertVisibilityBinding(WebBrowser browser, string browserName)
        {
            BindingExpression visibilityBinding = browser.GetBindingExpression(UIElement.VisibilityProperty);

            Assert.That(visibilityBinding, Is.Not.Null, $"No binding found for the 'Visibility' property of '{browserName}'.");
            return(visibilityBinding);
        }