質問

I am using the Codeplex verison of Xceed datagrid.
But while showing the grid in form, 'Powered by Xceed' text is coming in top right of datagrid.
enter image description here

Is it possible to remove this? How?

役に立ちましたか?

解決

I tried this. It worked.

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

他のヒント

I wrote a short blog post on this the other day. I made a simple extension method to find the adorner layer and remove it.

 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;
   }
 }

You can read more about it here: http://blog.itsnotfound.com/2013/02/xceed-community-datagridcontrol-watermark-removal/

Also, @punker76 in my opinion and as is stated in a discussion thread on the community site, the removal of the watermark is not against the MSPL. The devs acknowledged how to remove the watermark using modifications to the source code. They are even working on a more acceptable solution. Please see the discussion here: http://wpftoolkit.codeplex.com/discussions/428413

I think that the simples way to remove the GroupByControl is to modify the FixedHeaders property:

 <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>

Just set value of property Visibility to "Collapsed" like in the example.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top