删除Xceed datagrid中的默认文本

时间:2012-12-27 09:48:59

标签: wpf wpfdatagrid xceed-datagrid xceed

我正在使用Xceed数据网格的Codeplex版本 但是在显示网格时,“Powered by Xceed”文本位于datagrid的右上角 enter image description here

可以删除吗?怎么样?

3 个答案:

答案 0 :(得分:7)

我试过这个。有效。

 <Style TargetType="{x:Type xcdg:HierarchicalGroupByControl}">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>  

答案 1 :(得分:2)

我前几天写了一篇短文。我做了一个简单的扩展方法来找到装饰层并将其删除。

 public static class XceedDataGridExtensions
 {
   public static void RemoveWaterMark(this DataGridControl grid)
   {
     object hgbc = XceedDataGridExtensions.FindChild<HierarchicalGroupByControl>(grid, null);
     AdornerLayer al = AdornerLayer.GetAdornerLayer(hgbc as Control);
     al.Visibility = System.Windows.Visibility.Collapsed;
   }

  static T FindChild<T>(DependencyObject parent, string childName) where T : DependencyObject
  {
     // Confirm parent and childName are valid.
     if (parent == null) return null;
       T foundChild = null;
     int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
     for (int i = 0; i < childrenCount; i++)
     {
       var child = VisualTreeHelper.GetChild(parent, i);
       // If the child is not of the request child type child
       T childType = child as T;
       if (childType == null)
       {
         // recursively drill down the tree
         foundChild = FindChild<T>(child, childName);
         // If the child is found, break so we do not overwrite the found child.
         if (foundChild != null) break;
       }
       else if (!string.IsNullOrEmpty(childName))
       {
         var frameworkElement = child as FrameworkElement;
         // If the child's name is set for search
         if (frameworkElement != null && frameworkElement.Name == childName)
         {
            // if the child's name is of the request name
            foundChild = (T)child;
            break;
         }
      }
      else
      {
         // child element found.
         foundChild = (T)child;
         break;
      }
    }

    return foundChild;
   }
 }

您可以在此处详细了解:http://blog.itsnotfound.com/2013/02/xceed-community-datagridcontrol-watermark-removal/

另外,@ punker76在我看来并且如社区网站上的讨论主题所述,删除水印不是针对MSPL。开发人员承认如何使用对源代码的修改来删除水印。他们甚至致力于更可接受的解决方案。请参阅此处的讨论:http://wpftoolkit.codeplex.com/discussions/428413

答案 2 :(得分:1)

我认为删除GroupByControl的简单方法是修改FixedHeaders属性:

 <xcdg:DataGridControl  Grid.ColumnSpan="3"
                           UpdateSourceTrigger="CellContentChanged"
                           Grid.Row="8"
                           AutoCreateColumns="False"
                           IsDeleteCommandEnabled="True"
                           SelectionMode="Single"
                           ItemsSource="{Binding Instructions,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
        <xcdg:DataGridControl.View>
            <xcdg:TableView ShowRowSelectorPane="False"
                            UseDefaultHeadersFooters="False"
                            ColumnStretchMode="All">
                <xcdg:TableView.FixedHeaders>
                    <DataTemplate>
                        <DockPanel>
                            <xcdg:ColumnManagerRow DockPanel.Dock="Right"
                                                   AllowColumnReorder="False"
                                                   AllowColumnResize="False" />
                            <xcdg:GroupByControl x:Name="groupByControl"
                                                 Visibility="Collapsed" />
                        </DockPanel>
                    </DataTemplate>
                </xcdg:TableView.FixedHeaders>
            </xcdg:TableView>
        </xcdg:DataGridControl.View>
        <xcdg:DataGridControl.Columns>
            <xcdg:Column Title="Title"
                         FieldName="Title" />
            <xcdg:Column Title="Content"
                         FieldName="Content" />
            <xcdg:Column Title="Image Url"
                         FieldName="ImageUrl" />
        </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

只需将属性Visibility的值设置为&#34;折叠&#34;就像在例子中一样。

相关问题