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
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
Hi Petia,
I managed to solve the issue and it works great! Thanks for your help.
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.