2016-05-04 98 views
0

enter image description here在我的應用程序中,我綁定了數據網格。我寫了一個datagridcell的樣式,所有的樣式屬性都得到執行但不是文本包裝屬性。它正在修剪單元格內的數據。將文本包裹在DataGridCell中WPF

enter image description here

+0

您需要向我們展示的一些代碼 – bit

+0

可能的複製[如何得到一個WPF數據網格與細胞包裹文本,而不是截斷呢?](http://stackoverflow.com/questions/4671836/how-get -a-wpf-datagrid-with-cells-that-wrap-text-instead-of-truncating-it) – bit

+0

編輯:沒關係。發現問題。檢查下面的答案。 – jitendragarg

回答

0

您正在創建一個風格,但它不設置到DataGrid。將樣式標籤放入數據網格中。

<DataGrid --Your datagrid name here--> 
     <Style>        
      <-- your style code here --> 
     </Style> 
</DataGrid> 
+0

當我在datagrid中應用樣式時,它在使用itemssource之前顯示的項目集合必須爲空 –

+0

樣式與itemssource有什麼關係?你能用新代碼更新問題嗎?你知道,幫助我們幫助你嗎? – jitendragarg

+0

<數據網格名稱= 「dgUsers」 保證金= 「2」 VerticalGridLinesBrush = 「黑」 AlternatingRowBackground = 「古董白」> <形式的TargetType = 「{x:類型DataGridCell}」>