2013-07-10 96 views
0

我想編輯一個xamdatagrid,使其看起來像這樣編輯XamDataGrid標題

| updates |
|傳遞|失敗|
| 1 | 0 |
| 0 | 1 |
(我的間距不好,但你明白了) 我想在xamdatagrid上設置這個模板並將它綁定到數據集。 這可能嗎?並在可能的情況下,我在哪裏可以找到一個很好的例子在C#?我不斷髮現不好的和不完整的例子。

+0

這是什麼?頁眉? –

+0

假設「更新」是「通過」和「失敗」列的常見標題,那麼在Infragistics博客中有一個類似的例子:http://www.infragistics.com/community/blogs/alex_fidanov /archive/2010/06/02/howto-common-headers-in-the-xamdatagrid.aspx – alhalama

回答

2

您需要創建現場LabelPresenterStyle

<Style TargetType="{x:Type igWPF:LabelPresenter}" x:Key="PassedFailedLabelPresenterStyle"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type igWPF:LabelPresenter}"> 
       <TextBlock HorizontalAlignment="Center" Text="passed | failed" VerticalAlignment="Center" /> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

,並使用它像

<igWPF:Field Name="Hired" Width="Auto" LabelPresenterStyle="{StaticResource PassedFailedLabelPresenterStyle}"> 
+0

你可以在c#中提供一個例子嗎? – user1730250

+0

我在哪裏放置風格?你可以把這個例子的完整xaml? – user1730250

+0

您需要將其放入頁面xaml資源標籤內。 –