在Expression Blend中使用Silverlight Toolkit控件的XamlParseException

Dan*_*air 8 silverlight xaml silverlight-toolkit xamlparseexception expression-blend

我在使用Silverlight Toolkit控件时在Expression Blend中打开我的UserControl时遇到一个奇怪的问题.我的UserControl使用工具包的ListBoxDragDropTarget,如下所示:

<controlsToolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
        <ListBox ItemsSource="{Binding MyItemControls}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <controlsToolkit:WrapPanel/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
</controlsToolkit:ListBoxDragDropTarget>
Run Code Online (Sandbox Code Playgroud)

一切都在运行时按预期工作,在Visual Studio 2008中看起来很好.但是,当我尝试在Blend中打开我的UserControl时,我得到XamlParseException:[Line:0 Position:0],我在设计视图中看不到任何内容.更具体地说,Blend抱怨:

由于System.Windows.Controls.ListBoxDragDropTarget:TargetType不匹配的问题,无法显示元素"ListBoxDragDropTarget".

我的silverlight应用程序引用了2009年11月工具包版本中的System.Windows.Controls.Toolkit,我确保为ListBoxDragDropTarget包含这些命名空间声明:

xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:mswindows="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit"
Run Code Online (Sandbox Code Playgroud)

如果我注释掉ListBoxDragDropTarget控件包装器并且只是离开ListBox,我可以在设计视图中看到一切没有错误.此外,我意识到这种情况正在发生在各种Silverlight Toolkit控件上,因为如果我注释掉ListBoxDragDropTarget并将其替换为

<controlsToolkit:BusyIndicator />
Run Code Online (Sandbox Code Playgroud)

Blend中出现相同的确切错误.甚至更奇怪的是,如果我在混合中启动一个全新的silverlight应用程序,我可以添加这些工具包元素而不会出现任何错误,因此我的项目引用工具包程序集似乎发生了一些愚蠢的事情.

我很确定这与从generic.xaml加载工具包控件的默认样式有关,因为错误与TargetType有关,Blend可能正在尝试加载默认样式.

有没有人遇到过这个问题,或者有什么想法可能是我的问题?

Mic*_*Tol 11

嗨我们有完全相同的问题,我们通过检查项目中存在此问题的引用来解决它.所有引用的工具包程序集都应位于磁盘上的同一目录中.

我们对System.Windows.Controls.Toolkit.dll的项目引用总是"跳回"到导致我们问题的原始路径.我们通过在notepad ++(或任何您喜欢的文本编辑器)中编辑项目文件来解决,并硬编码它可以找到程序集的路径.

希望这可以帮助.


Sim*_*ver 5

对于Visual Studio(也可能是Blend),您需要添加对以下内容的引用:

System.Windows.Controls.Toolkit.Internals.dll

"C:\ Program Files\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Bin\System.Windows.Controls.Toolkit.Internals.dll"