Wpf 前缀';xcdg&x27;不映射到命名空间

Wpf 前缀';xcdg&x27;不映射到命名空间,wpf,xaml,controltemplate,xceed-datagrid,Wpf,Xaml,Controltemplate,Xceed Datagrid,我最近开始使用扩展WPF工具包中的DataGridControl <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}"> <xcdg:DataGridControl ItemsSource="{Binding Orders}" SelectionMode="Single" > <xcdg:DataGridContro

我最近开始使用扩展WPF工具包中的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>
但现在整个
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
添加到
DataGridControl
Style
之后。任何解释为什么会发生这种情况或如何避免这种情况都将不胜感激。

这只是VS2012 Xaml Designer的问题,VS Update 3已经解决了这一问题

这个问题似乎在VS2017中仍然存在。将绑定到具有命名空间的依赖项属性时引发异常

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

原始代码:


修改代码:



我发现VS2015更新3中的解决方案没有为我解决这个问题。仍然需要@itsho提供的解决方案。
<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>
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
<DataTrigger Binding="{Binding Path=(xcdg:DataGridControl.DataGridContext).IsConnectionStateGlyphEnabled, RelativeSource={RelativeSource Self}}" Value="False">