代码之家  ›  专栏  ›  技术社区  ›  Igor Zevaka

wpftoolkit datagrid在Windows Phone 7中不工作

  •  4
  • Igor Zevaka  · 技术社区  · 14 年前

    我想用wpftoolkit DataGrid 在WindowsPhone7项目(Silverligt4)中,它不起作用。这是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
    Type universe cannot resolve assembly: PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
       at System.Reflection.Adds.AssemblyProxy.GetResolvedAssembly()
       at System.Reflection.Adds.AssemblyProxy.get_FullName()
       at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.PrepareAttributes(Reflectable`1 reflectableAssembly)
       at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.PrepareAttributes(Reflectable`1 reflectableType)
       at MS.Internal.Metadata.ClrType.GetAttributes[T](ReflectionMetadataContext context, IReflectable`1 member, ITypeMetadata attributeType, Boolean merge, AttributeMergeCache& cache)
       at MS.Internal.Metadata.ClrMember`1.GetLocalAttributes(ITypeMetadata attributeType)
       at MS.Internal.Design.Metadata.Xaml.XamlType.GetSpecialProperty(Int32 idx, PropertyIdentifier pid)
       at MS.Internal.Design.Metadata.Xaml.XamlType.get_ContentProperty()
       at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetContentProperty(ITypeMetadata sourceType)
       at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetContentProperty(ITypeMetadata source)
       at MS.Internal.Design.Metadata.ReflectionTypeNode.get_ContentProperty()
       at MS.Internal.Design.Markup.XmlElement.CalcChildWhitespaceImportant(XamlElement element)
       at MS.Internal.Design.Markup.XmlElement.ConvertChildrenToXaml(XamlElement result, PrefixScope scope, IParseContext context, IMarkupSourceProvider provider, Boolean childrenAsString)
       at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
       at MS.Internal.Design.Markup.XmlElement.ConvertChildrenToXaml(XamlElement result, PrefixScope scope, IParseContext context, IMarkupSourceProvider provider, Boolean childrenAsString)
       at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
       at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.ParseElementFromSkeleton(XamlParseContext context, SkeletonNode node, XamlElement parent, Boolean fullElement)
       at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.UpdateSkeleton(IDamageListener listener)
       at Microsoft.Windows.Design.DocumentModel.Trees.MarkupDocumentTreeManager.Update()
       at Microsoft.Windows.Design.DocumentModel.MarkupProducer.Update()
       at Microsoft.Windows.Design.DocumentModel.MarkupProducer.HandleMessage(DocumentTreeCoordinator sender, MessageKey key, MessageArguments args)
       at Microsoft.Windows.Design.DocumentModel.MarkupProducer.Microsoft.Windows.Design.DocumentModel.IDocumentTreeConsumer.HandleMessage(DocumentTreeCoordinator sender, MessageKey key, MessageArguments args)
       at Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.SendMessage[T](MessageKey`1 key, T args, Boolean isPrivateMessage)
       at Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.QueuedMessage`1.Microsoft.Windows.Design.DocumentModel.IQueuedMessage.Invoke()
       at Microsoft.Windows.Design.DocumentModel.DocumentTreeCoordinator.ProcessQueuedMessages(Object state)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    
    
    1 回复  |  直到 14 年前
        1
  •  3
  •   Igor Zevaka    14 年前

    就在我正要发帖的时候,stackoverflow标签自动提示显示 Silverlight Toolkit . 显然这是我应该用的。

    既然我把所有的精力都放在了问题上,我就把问题和答案留给一个测试者,让它在自动回答我的问题时显得格外的令人敬畏。

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

    1. 系统.componentmodel.dataannotations.dll
    2. 系统.windows.controls.data.dll
    3. 系统.windows.controls.data.input.dll
    4. 系统.windows.data.dll
    推荐文章