2011-12-12 70 views

回答

1

你可以使用這樣的事情:

<DataGrid.Resources> 
    <DataTemplate x:Key="cellTemplate1"> 
     <Grid> 
      … 
     </Grid> 
    </DataTemplate>  
    <DataTemplate x:Key="cellTemplate2"> 
     <Grid> 
      … 
     </Grid> 
    </DataTemplate> 
    <DataTemplate x:Key="cellTemplate3"> 
     <Grid> 
      … 
     </Grid> 
    </DataTemplate> 
</DataGrid.Resources> 

<DataGrid.Columns>     
    <DataGridTemplateColumn CellTemplate="{StaticResource cellTemplate1}" /> 
    <DataGridTemplateColumn CellTemplate="{StaticResource cellTemplate2}" /> 
    <DataGridTemplateColumn CellTemplate="{StaticResource cellTemplate3}" /> 
</DataGrid.Columns> 

cellTemplate1將模板整個第一列,cellTemplate2 - 爲第二列等

+0

它只會改變單元模板而不是其中的項目 – Rabi

+0

ooookay .....你能描述一下你想把什麼東西放到你的數據網格的行中嗎? (與每欄的說明) – Anthony

+0

我有包含名稱和信息的項目。我必須根據名稱(在左邊)顯示帶有圖標的名稱。和信息在右邊。並且所有這些都必須列出 – Rabi

0

使用DataGrid。處理色譜柱要好得多。

+0

沒有像項目template.i屬性只需設置模板的項目在列 – Rabi

+0

使用'DataGridTemplateColumn'模板化單個列。 – Asti

+0

ok.i增加了this.but在它只有屬性的單元格模板,但我需要項目模板 – Rabi

0

你可以做到這一點,但設置GridViewColumn.CellTemplate財產。 ...它可讓您的Column你希望它是方式.. :)

<ListView Name="lv" 
         ItemsSource="{Binding Path=MyFavList}"> 
    <GridView> 
     <GridViewColumn> 
      <GridViewColumn.CellTemplate> 
       <DataTemplate> 
         <!--Your Fav Controls--> 
       </DataTemplate> 
      </GridViewColumn.CellTemplate> 
     </GridViewColumn> 
    </GridView> 

    </ListView > 

我想這應該求解的問題... :)雖然DataGrid是一個更好的選擇,只要開箱即用的功能與...;)

相關問題