2017-05-01 58 views
1

我用這個兩answeranswer 2如何可以把行號在DataGridRowHeader與出衝突行標題風格

他們的工作好了,但這些都是在設置Horizo​​ntalContentAlignment =「中心」 時有RowHeaderstyle例如衝突xaml或當用TextBlock改變寺廟時我有同樣的問題,它對內容沒有影響! (我改變了數據網格的寺廟)!!! 但現在我找不到問題:\ 爲什麼會出現此問題? 坦 XAML代碼:

enter code here 

    <Style TargetType="{x:Type DataGridRow}"> 
     <Setter Property="Background" Value="White" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
         <ControlTemplate TargetType="{x:Type DataGridRow}"> 
          <Border x:Name="DGR_Border" 
             BorderBrush="{TemplateBinding BorderBrush}" 
             BorderThickness="{TemplateBinding BorderThickness}" 
              SnapsToDevicePixels="True" Background="White">    

           <SelectiveScrollingGrid> 
            <SelectiveScrollingGrid.ColumnDefinitions> 
             <ColumnDefinition Width="Auto" /> 
             <ColumnDefinition Width="*" /> 
            </SelectiveScrollingGrid.ColumnDefinitions> 
            <SelectiveScrollingGrid.RowDefinitions> 
             <RowDefinition Height="*" /> 
             <RowDefinition Height="Auto" /> 
            </SelectiveScrollingGrid.RowDefinitions> 
            <DataGridCellsPresenter Grid.Column="1" 
             ItemsPanel="{TemplateBinding ItemsPanel}" 
             SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> 
            <DataGridDetailsPresenter Grid.Row="1" 
             Grid.Column="1" 
             SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding 
             AreRowDetailsFrozen, 
             ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, 
              Converter={x:Static DataGrid.RowDetailsScrollingConverter}, 
              RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" 
             Visibility="{TemplateBinding DetailsVisibility}" /> 
          <DataGridRowHeader Grid.RowSpan="2" Width="50" Background="Beige" HorizontalAlignment="Center" HorizontalContentAlignment="Center" 
             SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" 
             Visibility="{Binding HeadersVisibility, 
          ConverterParameter={x:Static DataGridHeadersVisibility.Row}, 
           Converter={x:Static DataGrid.HeadersVisibilityConverter}, 
           RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"> 


          </DataGridRowHeader> 
         </SelectiveScrollingGrid> 
          </Border> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 

    </Style> 
enter code here 
+0

您需要更好地解釋是什麼問題。什麼元素不像你想要的那樣行事,你想要的行爲是什麼? – Mishka

+0

嗨米什卡。我無法使用Horizo​​ntalContentAlignment =「Center」作爲dataGridRowHeadar內容,這是我的基本問題。 – amirhossein

回答

0

是似乎在DataGridRowHeader默認模板,還有就是Horizo​​ntalContentAlignment沒有參考:

https://msdn.microsoft.com/en-us/library/ff506248(v=vs.110).aspx

尋找:

<Style TargetType="{x:Type DataGridRowHeader}"> 

我會建議你重寫它的默認樣式和模板,所以你可以改變Hori內容的zontalAlignment。

+0

感謝您的幫助,問題出在RowHeaderStyle中。 – amirhossein