Hi there,
I am created an application using MVVC and currently using a XamGrid to display email configurations. I want one of the columns in the results to be readonly and not editable. I tried adding the ReadOnly=True on the XAML, but since I have a Add New Row setting aswell, setting this to true, doesnt allow me to input anything in this row when creating a new row. Is there a way to set the readonly property on the results without affecting the ReadOnly column?
Thanks in advance,
Julio
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Hi Petia,
I managed to solve the issue and it works great! Thanks for your help.
Yes, this seems to be what I need to achieve for my application. I am currently binding the ItemSource on the grid to an Observable collection, and then binding each individual TextColumn to the Key in the properties of the collection. However, when using your approach and Binding the Text on the TextBlock and TextBox to the object property, it says it cannot resolve the symbol and I get the following exception when running it:
'Add value to collection of type 'Infragistics.Controls.Grids.ColumnBaseCollection' threw an exception.'
Hope this information helps you understand the issue,
Thanks
Hi Julio,
If I properly understand your question, you need to be able to change a column cell value when adding a row and not changing it in on Editing. This could be achieved using a TemplateColumn with a TextBox as an EditorTemplate and change its IsReadOnly property value starting editing depending on what is started – editing or adding. Here is a sample code snippet:
<ig:XamGrid x:Name="Grid1" CellEnteredEditMode="Grid1_CellEnteredEditMode" CellExitingEditMode="Grid1_CellExitingEditMode" …………..…>
……………………….
<ig:TemplateColumn Key="PropertyName">
<ig:TemplateColumn.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ig:TemplateColumn.ItemTemplate>
<ig:TemplateColumn.EditorTemplate>
<TextBox x:Name="NameEditorTemplateTextBox" Text="{Binding PropertyName}" IsReadOnly="True" />
</ig:TemplateColumn.EditorTemplate>
</ig:TemplateColumn>
private void Grid1_CellExitingEditMode(object sender, ExitEditingCellEventArgs e)
{
if (e.Cell.Column.Key == "Name" && !e.EditingCanceled && e.Cell is AddNewRowCell)
TextBox tb = e.Editor as TextBox;
tb.IsReadOnly = true;
}
private void Grid1_CellEnteredEditMode(object sender, EditingCellEventArgs e)
if (e.Cell.Column.Key == "Name" && e.Cell is AddNewRowCell)
tb.IsReadOnly = false;
Let me know if this helps.
Thank you!
Petia