Friday, 15 June 2012

c# - How to make DataGridColumn ReadOnly but with CaretVisible? -


Is there a datagrid with the columns in read only mode but with the caret view? Similar to a textbox while using assets? If you set the IsReadOnly property then the column is disabled and it is not possible to click on the cell.

DataGrid ItemsSource = "{Binding Customers}" AutoGenerateColumns = "False" & gt; & Lt; DataGrid.Columns & gt; & Lt; DataGridTextColumnBinding = "{Binding Name}" & gt; & Lt; / DataGridTextColumn & gt; & Lt; DataGridTextColumnBinding = "{Binding Income}" IsReadOnly = "True" & gt; & Lt; / DataGridTextColumn & gt; & Lt; /DataGrid.Columns> & Lt; / Data grid & gt;

You can create a DataGridTemplateColumn with TextGox. See the code below.

  & lt; DataGridTemplateColumn header = "name" & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text box text = "{binding name}" IsReadOnly = "True" IsReadOnlyCaretVisible = "True" /> & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt;  

No comments:

Post a Comment