【问题标题】:WpfToolkit DataGrid does not work in Windows Phone 7WpfToolkit DataGrid 在 Windows Phone 7 中不起作用
【发布时间】:2010-03-23 11:43:29
【问题描述】:

我正在尝试在 Windows Phone 7 项目(Silverligt 4)中使用 WpfToolkit DataGrid,但它不起作用。这是 XAML:

<UserControl x:Class="SilverlightControls.Grid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:wtk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot" Background="#FF1F1F1F" Width="960">
        <Grid x:Name="TitleGrid">
            <TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextPageTitle2Style}"/>
        </Grid>
        <wtk:DataGrid>
        </wtk:DataGrid>
    </Grid>
</UserControl>

项目编译正常,但在运行时尝试加载此控件时崩溃。到目前为止,我得到的最好的线索来自 Visual Studio Designer。一旦我将wtk:DataGrid 添加到视觉设计器不会加载的控件,下面是它显示的异常。

会不会是 WpfToolkit 依赖 PresentationFramework.dll 而在 SL4 中不可用?

System.Reflection.Adds.UnresolvedAssemblyException 类型 Universe 无法解析程序集:PresentationFramework,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35。 在 System.Reflection.Adds.AssemblyProxy.GetResolvedAssembly() 在 System.Reflection.Adds.AssemblyProxy.get_FullName() 在 Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.PrepareAttributes(Reflectable`1 reflectableAssembly) 在 Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.PrepareAttributes(Reflectable`1 reflectableType) 在 MS.Internal.Metadata.ClrType.GetAttributes[T](ReflectionMetadataContext 上下文,IReflectable`1 成员,ITypeMetadata 属性类型,布尔合并,AttributeMergeCache& 缓存) 在 MS.Internal.Metadata.ClrMember`1.GetLocalAttributes(ITypeMetadata attributeType) 在 MS.Internal.Design.Metadata.Xaml.XamlType.GetSpecialProperty(Int32 idx,PropertyIdentifier pid) 在 MS.Internal.Design.Metadata.Xaml.XamlType.get_ContentProperty() 在 Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetContentProperty(ITypeMetadata sourceType) 在 Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetContentProperty(ITypeMetadata 源) 在 MS.Internal.Design.Metadata.ReflectionTypeNode.get_ContentProperty() 在 MS.Internal.Design.Markup.XmlElement.CalcChildWhitespaceImportant(XamlElement 元素) 在 MS.Internal.Design.Markup.XmlElement.ConvertChildrenToXaml(XamlElement 结果,PrefixScope 范围,IParseContext 上下文,IMarkupSourceProvider 提供程序,布尔 childrenAsString) 在 MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent,PrefixScope parentScope,IParseContext 上下文,IMarkupSourceProvider 提供程序) 在 MS.Internal.Design.Markup.XmlElement.ConvertChildrenToXaml(XamlElement 结果,PrefixScope 范围,IParseContext 上下文,IMarkupSourceProvider 提供程序,布尔 childrenAsString) 在 MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent,PrefixScope parentScope,IParseContext 上下文,IMarkupSourceProvider 提供程序) 在 MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.ParseElementFromSkeleton(XamlParseContext 上下文,SkeletonNode 节点,XamlElement 父级,布尔全元素) 在 MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.UpdateSkeleton(IDamageListener 监听器) 在 Microsoft.Windows.Design.DocumentModel.Trees.MarkupDocumentTreeManager.Update() 在 Microsoft.Windows.Design.DocumentModel.MarkupProducer.Update() 在 Microsoft.Windows.Design.DocumentModel.MarkupProducer.HandleMessage(DocumentTreeCoordinator 发件人,MessageKey 键,MessageArguments 参数) 在 Microsoft.Windows.Design.DocumentModel.MarkupProducer.Microsoft.Windows.Design.DocumentModel.IDocumentTreeConsumer.HandleMessage(DocumentTreeCoordinator 发件人,MessageKey 键,MessageArguments 参数) 在 Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.SendMessage[T](MessageKey`1 键,T args,布尔 isPrivateMessage) 在 Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.QueuedMessage`1.Microsoft.Windows.Design.DocumentModel.IQueuedMessage.Invoke() 在 Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.ProcessQueuedMessages(对象状态) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象 args,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象 args,Int32 numArgs,委托 catchHandler)

【问题讨论】:

    标签: silverlight-4.0 wpftoolkit windows-phone-7


    【解决方案1】:

    就在我即将发布问题时,StackOverflow 标签自动建议显示有Silverlight Toolkit。显然这是我应该使用的。

    由于我在问题上付出了所有努力,因此我将把问题和答案作为 StackOverflow 在自动回答我的问题方面的出色表现的证明。

    编辑 您需要 Silverlight 3 Toolkit 二进制文件才能使用 DataGrid。您需要将这四个引用添加到项目中:

    1. System.ComponentModel.DataAnnotations.dll
    2. System.Windows.Controls.Data.dll
    3. System.Windows.Controls.Data.Input.dll
    4. System.Windows.Data.dll

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2013-04-06
      • 1970-01-01
      相关资源
      最近更新 更多