前缀“xcdg”未映射到命名空间

2023-12-23

我最近开始使用 Extended WPF Toolkit 中的 DataGridControl

<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
    <xcdg:DataGridControl ItemsSource="{Binding Orders}" SelectionMode="Single" >
        <xcdg:DataGridControl.View>
            <xcdg:TableflowView FixedColumnCount="1" UseDefaultHeadersFooters="True" ShowRowSelectorPane="False" VerticalGridLineBrush="Green" VerticalGridLineThickness="2" HorizontalGridLineBrush="Purple" HorizontalGridLineThickness="2">
                <xcdg:TableflowView.Theme>
                    <xcdg:ZuneNormalColorTheme/>
                </xcdg:TableflowView.Theme>
            </xcdg:TableflowView>
        </xcdg:DataGridControl.View>
        <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="OrderID" IsMainColumn="True"/>
            <xcdg:Column FieldName="ExternalID" />
            <xcdg:Column FieldName="CustomerName" />
            <xcdg:Column FieldName="Date" />
            <xcdg:Column FieldName="Address" />
            <xcdg:Column FieldName="Items" Width="*" />
        </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
</Grid>

没关系,一切正常。然后我添加了样式。

<Style TargetType="{x:Type xcdg:DataGridControl}">
    <Setter Property="Background" Value="MediumOrchid"/>
</Style>

Style已应用,一切再次正常。所以我接下来要做的是创造CotrolTemplate使用 Expression Blend 并将该模板添加到我的样式中。

<Style TargetType="{x:Type xcdg:DataGridControl}">
  <Setter Property="Background"
          Value="MediumOrchid" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type xcdg:DataGridControl}">
        <Grid>
          <Border BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Background="{TemplateBinding Background}">
            <AdornerDecorator x:Name="PART_DragDropAdornerDecorator">
              <xcdg:TableViewScrollViewer x:Name="PART_ScrollViewer"
                                          Padding="{TemplateBinding Padding}"
                                          RowSelectorPaneWidth="{Binding (xcdg:DataGridControl.DataGridContext).RowSelectorPaneWidth, RelativeSource={RelativeSource Self}}"
                                          ShowRowSelectorPane="{Binding (xcdg:DataGridControl.DataGridContext).ShowRowSelectorPane, RelativeSource={RelativeSource Self}}">
                <xcdg:TableflowViewItemsHost />
              </xcdg:TableViewScrollViewer>
            </AdornerDecorator>
          </Border>
          <Grid x:Name="connectionStateGrid"
                HorizontalAlignment="Right"
                Height="30"
                Margin="0,0,25,25"
                VerticalAlignment="Bottom"
                Width="30">
            <ContentPresenter x:Name="connectionStateLoadingContentPresenter"
                              ContentTemplate="{Binding (xcdg:DataGridControl.DataGridContext).ConnectionStateLoadingGlyph, RelativeSource={RelativeSource Self}}"
                              Content="{TemplateBinding ConnectionState}"
                              Visibility="Collapsed" />
            <ContentPresenter x:Name="connectionStateCommittingContentPresenter"
                              ContentTemplate="{Binding (xcdg:DataGridControl.DataGridContext).ConnectionStateCommittingGlyph, RelativeSource={RelativeSource Self}}"
                              Content="{TemplateBinding ConnectionState}"
                              Visibility="Collapsed" />
            <ContentPresenter x:Name="connectionStateErrorContentPresenter"
                              ContentTemplate="{Binding (xcdg:DataGridControl.DataGridContext).ConnectionStateErrorGlyph, RelativeSource={RelativeSource Self}}"
                              Content="{TemplateBinding ConnectionState}"
                              Visibility="Collapsed" />
          </Grid>
        </Grid>
        <ControlTemplate.Triggers>
          <DataTrigger Binding="{Binding (xcdg:DataGridControl.DataGridContext).IsConnectionStateGlyphEnabled, RelativeSource={RelativeSource Self}}"
                       Value="False">
            <Setter Property="Visibility"
                    TargetName="connectionStateGrid"
                    Value="Collapsed" />
          </DataTrigger>
          <DataTrigger Binding="{Binding (xcdg:DataGridControl.DataGridContext).DataGridControl.ConnectionState, RelativeSource={RelativeSource Self}}"
                       Value="Loading">
            <Setter Property="Visibility"
                    TargetName="connectionStateLoadingContentPresenter"
                    Value="Visible" />
            <Setter Property="Visibility"
                    TargetName="connectionStateErrorContentPresenter"
                    Value="Collapsed" />
            <Setter Property="Visibility"
                    TargetName="connectionStateCommittingContentPresenter"
                    Value="Collapsed" />
          </DataTrigger>
          <DataTrigger Binding="{Binding (xcdg:DataGridControl.DataGridContext).DataGridControl.ConnectionState, RelativeSource={RelativeSource Self}}"
                       Value="Committing">
            <Setter Property="Visibility"
                    TargetName="connectionStateLoadingContentPresenter"
                    Value="Collapsed" />
            <Setter Property="Visibility"
                    TargetName="connectionStateErrorContentPresenter"
                    Value="Collapsed" />
            <Setter Property="Visibility"
                    TargetName="connectionStateCommittingContentPresenter"
                    Value="Visible" />
          </DataTrigger>
          <DataTrigger Binding="{Binding (xcdg:DataGridControl.DataGridContext).DataGridControl.ConnectionState, RelativeSource={RelativeSource Self}}"
                       Value="Error">
            <Setter Property="Visibility"
                    TargetName="connectionStateLoadingContentPresenter"
                    Value="Collapsed" />
            <Setter Property="Visibility"
                    TargetName="connectionStateErrorContentPresenter"
                    Value="Visible" />
            <Setter Property="Visibility"
                    TargetName="connectionStateCommittingContentPresenter"
                    Value="Collapsed" />
          </DataTrigger>
        </ControlTemplate.Triggers>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

但现在整个ControlTemplate带有下划线,上面写着

前缀“xcdg”不映射到命名空间。

xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"

都在我的资源字典和窗口中。此外,xaml 设计器在放置“DataGridControl”的“MainWindow.xaml”中引发异常。它是

ArgumentException:“{DependencyProperty.UnsetValue}”不是 Setter 上“System.Windows.Controls.Control.Template”属性的有效值。

在运行时它工作正常。一切都发生在我添加之后ControlTemplate to Style of DataGridControl。任何解释为什么会发生这种情况或如何避免这种情况将受到高度赞赏。


貌似VS2017还存在这个问题。使用命名空间绑定依赖属性时会引发异常。

我找到的解决方案是显式添加Path=到绑定。

原始代码:

<DataTrigger Binding="{Binding (xcdg:DataGridControl.DataGridContext).IsConnectionStateGlyphEnabled, RelativeSource={RelativeSource Self}}" Value="False">

修改后的代码:

<DataTrigger Binding="{Binding Path=(xcdg:DataGridControl.DataGridContext).IsConnectionStateGlyphEnabled, RelativeSource={RelativeSource Self}}" Value="False">

我找到了解决方案海因里希·乌布利希博客 http://sharepointbrainpump.blogspot.co.il/2012/12/solved-prefix-does-not-map-to-a-namespace-when-binding-to-a-custom-dependency-property.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

前缀“xcdg”未映射到命名空间 的相关文章

随机推荐

  • 我是否在 java.io.PipedInputStream 中发现了错误?

    我不确定 但我非常确定我在 Oracle Java 实现中发现了一个错误 或未记录的功能 我可以验证 1 7 0 67 和 1 8 0 31 是否受影响 症状 当管道已满时 对管道的写入可能会比管道再次空闲所需的时间多等待一秒 该问题的一个
  • iPhone SDK 3.0 - wait_fences:未能收到回复:10004003 [重复]

    这个问题在这里已经有答案了 我一直在开发 iPhone 应用程序 自从我开始在 SDK 3 0 上构建以来 每当应用程序尝试与我的网络服务器通信时 我都会收到此错误 一切似乎都运行良好 但我找不到任何可以解释该消息的根本原因的内容 任何帮助
  • 使用 userEvent.click 错误的 act() 警告响应测试库

    我有几个用 Jest 和 React 测试库编写的测试 它们都模拟获取并使用 userEvent click 调用来触发发出获取请求的提交按钮 组件中的状态得到更新 我做出断言 我正在使用 useEffect 挂钩来填充数据数组 但它仅在初
  • 如何使用 Youtube v3 API 获取 Youtube 视频的 mp4 url

    如何获取完整的 mp4 url 以使用除 Youtube 之外的其他来源从应用程序中的实际位置播放视频 gdata youtube API 已被弃用 所以我遇到了麻烦 任何帮助将不胜感激 谢谢 我做了一个非常简单的API https gis
  • 如何将休眠与 MS Access 结合使用?

    我想将休眠与 MS Access 一起使用 我应该使用哪种方言 您能给我一个带有 MS Access 的休眠配置文件示例吗 实际解决方案在这里 在花了 1 天尝试不同的解决方案 ODBC HXTT 等之后 我发现了这个美妙之处 http u
  • ASP.NET Core 路由不起作用

    路由器的配置方式如下 app UseMvc routes gt routes MapRoute name api template api action id app UseMvc routes gt routes MapRoute nam
  • 为什么 nl_langinfo(CODESET) 与 locale charmap 不同?

    此帖源自如何获取您的系统在 c c 中使用哪种编码 https stackoverflow com questions 1492918 how do you get what kind of encoding your system use
  • 从 Excel 单元格读取

    我在用EPPlus http epplus codeplex com 用于从 xlsx 文件读取的包 我需要从单元格中读取 TimeSpan 对象 Excel 单元格将包含 hh mm 格式的数据 例如 09 00 或 18 30 不带引号
  • Lua Web 开发使用什么 Web 服务器 [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • Zend_Paginator 作为对象返回

    Zend Paginator 将结果作为标准数组返回 但我需要使结果作为类的实例返回 我该怎么做 例如 我想要所有新闻文章 因此需要我的项目作为 News Model Article 的实例返回 您还可以创建自定义 zend paginat
  • 如何从网页中的多个表中抓取内容

    我想从网页中的多个表中抓取内容 HTML 代码如下所示 div class fixtures table full table medium h2 class table header Date 1 h2 table class table
  • 解释基本 Prolog 结果

    我对 Prolog 的基础知识感到困惑 如果我有这个知识库 loves vincent mia loves marcellus mia loves pumpkin honey bunny loves honey bunny pumpkin
  • 当软键盘出现时,工具栏向上移动

    我想让我的活动布局在键盘出现时调整大小 但同时保持其工具栏位置不变 到目前为止 当我单击编辑文本并出现键盘时 所有屏幕都会向上移动 Before keyboard appears 键盘出现后 工具栏不再可见 我想将键盘保留在其位置并将图像移
  • 从 Git 存储库中删除已从磁盘删除的多个文件

    我有一个 Git 存储库 已删除了四个使用中的文件rm not git rm 我的 Git 状态如下所示 deleted file1 txt deleted file2 txt deleted file3 txt deleted file4
  • Go:如何检查结构体属性是否显式设置为零值?

    type Animal struct Name string LegCount int snake Animal Name snake LegCount 0 worm Animal Name worm 问题 我怎样才能检查snake and
  • 如何延长一条线与多边形相交?

    我想延长线以接触多边形 创建直线和多边形 直线和多边形 这是我的 拉伸和修剪 解决方案 结果比我最初提供的第一个 解决方案 要棘手一些 我还包括了水平线和垂直线的情况 我认为我的例子涵盖了all案例 线方向 我的编码非常简单 没有努力提高效
  • C# 结构体中的数组

    想要这样做 编辑 错误的示例代码 忽略并跳过下面 struct RECORD char name new char 16 int dt1 struct BLOCK char version new char 4 int field1 int
  • Doctrine QueryBuilder:多对一关系,其中多个子实体必须匹配

    我正在尝试在有实体的地方进行查询Job和一个实体JobProperty其中 1Job可以有很多JobProperties 使用 Doctrine 和 Symfony2 查询多对多关系 https stackoverflow com ques
  • 如何正确配置 babel 来使用 lodash-es?

    我需要使用lodash es在我的项目中 但我无法正确配置我的babel 它总是报告错误 例如SyntaxError Unexpected identifier hello js import upperCase from lodash e
  • 前缀“xcdg”未映射到命名空间

    我最近开始使用 Extended WPF Toolkit 中的 DataGridControl