相关疑难解决方法(0)

在WPF中数据绑定WebBrowser的Source属性

有谁知道如何在WPF(3.5SP1)中数据绑定WebBrowser的.Source属性?我有一个listview,我希望在左边有一个小的WebBrowser,在右边有内容,并在每个WebBrowser的源中为每个绑定到列表项的对象中的URI进行数据绑定.

这是我迄今为止的概念证明,但" <WebBrowser Source="{Binding Path=WebAddress}""不编译.

<DataTemplate x:Key="dealerLocatorLayout" DataType="DealerLocatorAddress">                
    <StackPanel Orientation="Horizontal">
         <!--Web Control Here-->
        <WebBrowser Source="{Binding Path=WebAddress}"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
            ScrollViewer.VerticalScrollBarVisibility="Disabled" 
            Width="300"
            Height="200"
            />
        <StackPanel Orientation="Vertical">
            <StackPanel Orientation="Horizontal">
                <Label Content="{Binding Path=CompanyName}" FontWeight="Bold" Foreground="Blue" />
                <TextBox Text="{Binding Path=DisplayName}" FontWeight="Bold" />
            </StackPanel>
            <TextBox Text="{Binding Path=Street[0]}" />
            <TextBox Text="{Binding Path=Street[1]}" />
            <TextBox Text="{Binding Path=PhoneNumber}"/>
            <TextBox Text="{Binding Path=FaxNumber}"/>
            <TextBox Text="{Binding Path=Email}"/>
            <TextBox Text="{Binding Path=WebAddress}"/>
        </StackPanel>
    </StackPanel>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

c# browser data-binding wpf xaml

85
推荐指数
3
解决办法
5万
查看次数

从WebBrowser中的Document中的JavaScript调用C#代码

我有一个C#WinForms应用程序,里面有一个WebBrowser控件.我想在嵌入式Web浏览器控件中执行C#表单和JavaScript之间的双向通信.

我知道我可以使用InvokeScript调用JavaScript函数,但是如何从Document中的 JavaScript调用C#代码?我想由于安全性而不容易,但无论如何,它有可能吗?这些JavaScript函数应该是用户函数,就像宏一样,它会告诉WebBrowser在我自己编写的整个C#库的帮助下究竟该怎么做.由于这是一个Web scraper,因此JavaScript是这些宏的完美语言,因为它几乎可以访问HTML文档中的元素.

.net javascript c#

35
推荐指数
2
解决办法
5万
查看次数

标签 统计

c# ×2

.net ×1

browser ×1

data-binding ×1

javascript ×1

wpf ×1

xaml ×1