2017-02-08 1 views
0

DevExpress Grid Control이 있지만 헤더의 공간이 제한되어 있으므로 모든 텍스트가 맞지 않습니다. 약간 큰 여백이있을 수 있습니다.) 헤더에서 비록 내가 줄일 수 있다면 내 문제를 해결할 것입니다. 하지만 패딩이 어디에 있는지 알 수 없습니다. 열은 다음과 같이 정의된다DevExpress Grid Column 헤더의 여백/여백을 제거하는 방법

...

 <dxg:GridColumn 
      CellStyle="{StaticResource DefaultCellStyle}" 
      CellTemplate="{StaticResource TestCellValueTemplate}" 
      FieldName="Test2.DisplayValue" 
      Header="{Binding Columns.Test2Column}" 
      HeaderTemplate="{StaticResource TestColumnHeaderTemplate}" 
      HorizontalHeaderContentAlignment="Center" 
      Visible="{Binding Columns.Test2Column.IsVisible}" 
      VisibleIndex="2" /> 

그리고 HeaderTemplate

<DataTemplate 
     x:Key="TestColumnHeaderTemplate" 
     DataType="vsvm:FvcSessionGridTestColumn"> 
     <StackPanel 
      HorizontalAlignment="Stretch" 
      VerticalAlignment="Stretch" 
      Orientation="Vertical"> 
      <TextBlock 
       HorizontalAlignment="Stretch" 
       FontWeight="Bold" 
       Text="{Binding Header}" /> 
      <TextBlock 
       HorizontalAlignment="Center" 
       FontSize="11" 
       Text="{Binding Time, Mode=OneWay, StringFormat=HH:mm:ss}" /> 
     </StackPanel> 
    </DataTemplate> 

어디 마진이나 패딩 없음 언급이다. 그러나 내가 StackPanel의 너비를 제어 할 수는 있지만 사용 가능한 공간보다 크게 만들면 셀 패딩 뒤에 사라집니다.

나는 GridColumn 요소에

ColumnHeaderContentStyle="{StaticResource DefaultHeaderStyle}" 

(도)

<Style x:Key="DefaultHeaderStyle" 
      TargetType="{x:Type dxg:HeaderContentControl}"> 
     <Setter Property="Margin" Value="0, 0, 0, 0" /> 
     <Setter Property="Padding" Value="0, 0, 0, 0" /> 
     <Setter Property="Background" Value="Red" /> 
    </Style> 

을 추가하는 시도했지만 완전히 무시 될 것으로 보인다.

enter image description here

내가 시도하고 여백의 원인을 찾기 위해 "스눕"를 사용했습니다 협조 할 수 있습니다, 그것은 13, 12, 13, 12ContentMargin를 한 것으로 밝혀졌습니다. 이걸 변경하면 Snoop 내에서 작동하는 것 같습니다. 그러나 코드에서 이것이 적용되는 위치와 무시할 위치를 알 수는 없습니다.

enter image description here

답변

0

나는 결국 여기에 답을 발견 ...

https://www.devexpress.com/Support/Center/Question/Details/T241104

내 경우에는이 솔루션은 ColumnHeaderDockPanel에서 ContentMargin을 무시하는 것이 었습니다. <UserControl.Resources>

<ControlTemplate x:Key="{dxgt:GridColumnHeaderThemeKey ResourceKey=ControlTemplate, IsThemeIndependent=True}" TargetType="{x:Type dxg:GridColumnHeaderBase}"> 
     <dxg:ColumnHeaderDockPanel x:Name="PART_LayoutPanel" TextElement.Foreground="{DynamicResource {dxgt:GridColumnHeaderThemeKey ResourceKey=HeaderCaptionForeground}}" ContentMargin="2, 12, 2, 12" /> 
    </ControlTemplate> 

관련 문제