.net WPF WebBrowser控件自定义属性

.net WPF WebBrowser控件自定义属性,.net,wpf,vb.net,wpf-controls,vb.net-2010,.net,Wpf,Vb.net,Wpf Controls,Vb.net 2010,嗯。因此,我遇到了几个代码示例,说明我可以为WPF WebBrowser控件创建一个自定义属性,这将允许我将一个html字符串绑定到控件以进行呈现 以下是属性的类(位于名为BrowserHtmlBinding.vb的文件中): 以及Xaml: <Window x:Class="Details" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft

嗯。因此,我遇到了几个代码示例,说明我可以为WPF WebBrowser控件创建一个自定义属性,这将允许我将一个html字符串绑定到控件以进行呈现

以下是属性的类(位于名为BrowserHtmlBinding.vb的文件中):

以及Xaml:

<Window x:Class="Details"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:custom="clr-namespace:BrowserHtmlBinding"
Title="Task Details" Height="400" Width="800" Icon="/v2Desktop;component/icon.ico"
WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow"
WindowState="Maximized">
    <Grid>
        <WebBrowser custom:Html="&lt;b&gt;Hey Now&lt;/b&gt;" />
    </Grid>
</Window>

我一直收到一个错误:错误1在类型“WebBrowser”中找不到属性“Html”


我该如何解决这个问题???它快把我逼疯了

在xmlns映射中将名称列为命名空间,然后在实际附加的属性用法中不列出类名。我无法从您的代码片段中判断名称空间是什么(您可以检查项目属性以找到根名称空间),但假设它类似于WpfApplication1,xaml将如下所示

<Window x:Class="Details" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:custom="clr-namespace:WpfApplication1" 
  Title="Task Details" Height="400" Width="800" 
  Icon="/v2Desktop;component/icon.ico" WindowStartupLocation="CenterScreen"
  WindowStyle="ThreeDBorderWindow" WindowState="Maximized"> 
<Grid> 
    <WebBrowser custom:BrowserHtmlBinding.Html="&lt;b&gt;Hey Now&lt;/b&gt;" /> 
</Grid> 

<Window x:Class="Details" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:custom="clr-namespace:WpfApplication1" 
  Title="Task Details" Height="400" Width="800" 
  Icon="/v2Desktop;component/icon.ico" WindowStartupLocation="CenterScreen"
  WindowStyle="ThreeDBorderWindow" WindowState="Maximized"> 
<Grid> 
    <WebBrowser custom:BrowserHtmlBinding.Html="&lt;b&gt;Hey Now&lt;/b&gt;" /> 
</Grid>