Xceed DataGrid:删除详细行

时间:2017-09-14 12:54:38

标签: wpf datagrid header spacing xceed

enter image description here

如何删除Xceed在细节行之前自动放入的间距?通常这里有一个标题,但我把它设置为空,因为我不想要它。标记为红色的间距是最烦人的。

我发现更换这一行:

                <xcdg:DetailConfiguration RelationName="Settings" Title="">

这一行:

            <xcdg:DetailConfiguration RelationName="Settings" Title="" UseDefaultHeadersFooters="False">

将删除标记为红色的空格。但是它也删除了我的标题:

|名称|说明|编辑值|编辑值|

这是我的代码:

<UserControl.Resources>

    <!--#region DataTemplateSelector-->
    <local:SettingsDataTemplateSelector x:Key="SettingsDataTemplateSelector" />

    <DataTemplate x:Key="TextboxDataTemplate">
        <xcdg:MaskedTextBox IsTabStop="True" Mask="{Binding EditMask}" Text="{Binding EditValue, IsAsync=False, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnExceptions=True}"/>
    </DataTemplate>

    <DataTemplate x:Key="ComboDataTemplate">
        <ComboBox IsTabStop="True"  ItemsSource="{Binding Path=SelectionValues}"
                                    SelectedValuePath="Value"
                                    SelectedValue="{Binding Path=SelectionValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    DisplayMemberPath="ValueText">
        </ComboBox>
    </DataTemplate>

    <DataTemplate x:Key="SliderDataTemplate">
        <Slider IsTabStop="True" Value="{Binding EditSliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    Minimum="{Binding MinRangeValue}" 
                    Maximum="{Binding MaxRangeValue}"
                    VerticalAlignment="Bottom" 
                    IsSnapToTickEnabled="True"
                    TickFrequency="1"
                    Margin="0,0,0,0"/>
    </DataTemplate>
    <!--#endregion-->

    <xcdg:DataGridCollectionViewSource x:Key="Features" 
                                        Source ="{Binding Path=Demo.Features}"
                                        AutoFilterMode="And"
                                        AutoCreateDetailDescriptions="False" 
                                        AutoCreateItemProperties="False">
        <xcdg:DataGridCollectionViewSource.DetailDescriptions>
            <xcdg:PropertyDetailDescription RelationName="Settings" AutoCreateDetailDescriptions="False" AutoCreateItemProperties="False"/>
        </xcdg:DataGridCollectionViewSource.DetailDescriptions>
    </xcdg:DataGridCollectionViewSource>
</UserControl.Resources>

<Grid>
    <!--#region Xceed DataGrid-->
    <xcdg:DataGridControl x:Name="datagrid"
                          ItemsSource="{Binding Source={StaticResource Features}}"
                          KeyUp="DatagridKeyUp"
                          AllowDetailToggle="True" 
                          Margin="10"
                          NavigationBehavior="RowOrCell" 
                          CellEditorDisplayConditions="RowIsBeingEdited, 
                          MouseOverCell, MouseOverRow, RowIsCurrent, CellIsCurrent" 
                          EditTriggers="BeginEditCommand, ClickOnCurrentCell, 
                          SingleClick, CellIsCurrent, ActivationGesture, RowIsCurrent"
                          ItemScrollingBehavior="Immediate"
                          AutoCreateColumns="False">

        <xcdg:DataGridControl.Resources>
            <Style TargetType="xcdg:TableViewScrollViewer">
                <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
                <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
            </Style>
        </xcdg:DataGridControl.Resources>

        <xcdg:DataGridControl.View>
            <xcdg:TableflowView UseDefaultHeadersFooters="False" ColumnStretchMode="Last">
                <xcdg:TableflowView.FixedHeaders>
                    <DataTemplate>
                        <xcdg:ColumnManagerRow />
                    </DataTemplate>
                </xcdg:TableflowView.FixedHeaders>
            </xcdg:TableflowView>
        </xcdg:DataGridControl.View>

        <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="FeatureID" Title="FeatureID" ReadOnly="True" />
            <xcdg:Column FieldName="Name" Title="Feature name" ReadOnly="True" />
            <xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
            <xcdg:Column FieldName=" "/>
        </xcdg:DataGridControl.Columns>

        <xcdg:DataGridControl.DetailConfigurations>
            <xcdg:DetailConfiguration RelationName="Settings" Title="">
                <xcdg:DetailConfiguration.Columns>
                    <xcdg:Column FieldName="Name" Title="Name" ReadOnly="True"/>
                    <xcdg:Column FieldName="Description" Title="Description" ReadOnly="True"/>
                    <xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True"/>
                    <xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
                                 CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
                                 DisplayMemberBinding="{Binding}" />
                    <xcdg:Column FieldName=" "/>
                </xcdg:DetailConfiguration.Columns>
            </xcdg:DetailConfiguration>
        </xcdg:DataGridControl.DetailConfigurations>
    </xcdg:DataGridControl>
    <!--#endregion-->
</Grid>

编辑:我想出了如何摆脱蓝色间距,但仍然无法弄清楚如何摆脱红色。

代码:

<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
    <Setter Property="MaxWidth" Value="0" />
</Style>

您可能认为可以添加<Setter Property="MaxHeight" Value="0" />,但这不会做任何事情。

1 个答案:

答案 0 :(得分:0)

蓝色间距由HierarchicalGroupLevelIndicatorPane设置,这意味着只需将宽度设置为0即可摆脱它:

import { TestBed, async, inject } from '@angular/core/testing';

import { AngularFireAuth } from 'angularfire2/auth';
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Rx';

import { AuthService } from './auth.service';
import { MockUser} from './mock-user';
import { environment } from '../environments/environment';

describe('AuthService', () => {
  // An anonymous user
  const authState: MockUser = {
    displayName: null,
    isAnonymous: true,
    uid: '17WvU2Vj58SnTz8v7EqyYYb0WRc2'
  };

  const mockAngularFireAuth: any = {
    auth: jasmine.createSpyObj('auth', {
      'signInAnonymously': Promise.reject({
        code: 'auth/operation-not-allowed'
      }),
      // 'signInWithPopup': Promise.reject(),
      // 'signOut': Promise.reject()
    }),
    authState: Observable.of(authState)
  };

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        { provide: AngularFireAuth, useValue: mockAngularFireAuth },
        { provide: AuthService, useClass: AuthService }
      ]
    });
  });

  it('should be created', inject([ AuthService ], (service: AuthService) => {
    expect(service).toBeTruthy();
  }));

  …

  describe('catastrophically fails', () => {
    beforeEach(() => {
      const spy = spyOn(mockAngularFireAuth, 'authState');

      spy.and.returnValue(Observable.throw(new Error('Catastrophe')));
    });

    describe('AngularFireAuth.authState', () => {
      it('should invoke it’s onError function', () => {
        mockAngularFireAuth.authState.subscribe(null,
          (error: Error) => {
            expect(error).toEqual(new Error('Catastrophe'));
          });
      });
    });
  });
  …
});

红色间距有点困难。最后,我在DetailConfiguration上将UseDefaultHeadersFooters设置为false,这将删除空间以及ColumnManagerRow。然后我在DetailConfiguration.Headers中再次创建ColumnManagerRow。

代码如下所示:

<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
    <Setter Property="MaxWidth" Value="0" />
</Style>