WPF XAML编辑器在设计时错误,但应用程序在运行时工作正常



在日常工作中,我遇到了一个关于WPF XAML编辑器的问题。例如,我将在我的项目中使用动态数据显示。首先,我将dynamicdataddisplay . dll添加到我的项目中。然后我将为这个DLL添加一个特定的xmlns。但是我发现添加的DLL没有智能感知,我需要手动键入命名空间。代码如下:

<Window x:Class="WPFMonitor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
        Title="Monitor Window" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="CPU Usage" Margin="20,10,0,0"
                       FontSize="15" FontWeight="Bold"/>
            <TextBlock x:Name="cpuUsageText" Margin="10,10,0,0"
                       FontSize="15"/>
        </StackPanel>
        <d3:ChartPlotter x:Name="plotter" Margin="10,10,20,10" Grid.Row="1">
            <d3:ChartPlotter.VerticalAxis>
                <d3:VerticalIntegerAxis />
            </d3:ChartPlotter.VerticalAxis>
            <d3:ChartPlotter.HorizontalAxis>
                <d3:HorizontalIntegerAxis />
            </d3:ChartPlotter.HorizontalAxis>
            <d3:Header Content="CPU Performance History"/>
            <d3:VerticalAxisTitle Content="Percentage"/>
        </d3:ChartPlotter>
    </Grid>
</Window>
如您所见,我在XAML代码中引用了DLL,但是编辑器给了我关于 的错误。

找不到"d3:ChartPlotter"类型。确认你不是缺少一个程序集引用,而所有引用的程序集都有建成。

当我点击时,重新加载了设计器。我在VS 2010 SP1/VS 2013 Update2上测试了这个问题。但是如果我构建这个应用程序。没有错误,运行正常。

我不是一个说英语的人。如果你听不懂我的问题。请随时告诉我。我来澄清一下。

任何帮助将不胜感激!非常感谢!:)

我也遇到过类似的问题。一个可能的解决方案是获取源代码,如果可以的话,自己编译。dll文件,然后添加它作为参考。

当我之前使用的。dll文件在Visual Studio 13中编译时,在Visual Studio 15中为我工作。

希望能帮到别人

最新更新