Hi,
I have DataRecords with property, which "knows" if it should be editable for the user or not. Something like:
public class StringProperty
{
public string StringValue { get; set; }
public bool AllowEdit { get; private set; }
}
So I create a Field with Binding to the StringProperty property and a Template to display it and it works so far. But how can I bind the AllowEdit property of each cell (or CellValuePresenter) to the AllowEdit property of the data? (The AllowEdit is set by the business logic according some rules, such as expiration date, etc...).
Thanks in advance,
George
HI George,
I am attaching a sample that may help you resovle your issue.
Sincerely,
Matt
Developer Support Engineer
Hi Matt,
this works fine. But it uses the IsEnabled Property of the CellValuePresenter. Because of the look and feel, I would like to use the IsEditingAllowed, which is unfortunately a ReadOnly property. Can you tell me, what sets the IsEditingAllowed property? How can I control it?
Best Regards,
HI,
I am attaching a new sample that bindings the IsReadonlyProperty of each editor used by the XamDataGrid to a property in the class that the grid is bound to.
Hello Matt,
thank you for your samples. The last one is an efficient work-arround of what i want, but still wouldn't be enough for me.
I have many custom Editors - like Popups with a rich content. That is why, the user will be irritated if the editor opens and then it is in ReadOnly mode. What I really need is to prevent the user of entering edit mode. And not go in, but not be able to change.
Maybe this could be done with some event handling? I suppose EditModeStarting event would somehow do the job.
But as I asked already in the first post, I am looking for Binding possibility. Is there some? Or should I try it with the event handling?
You could use the EDitModeStarting Event and cancel it.
I think the best soltuion was the first one I provided, It used the IsEnabled Property of the CellValuePresenter.
This prevented going into edit mode and it also styled the row so that the enduser will know its readonly.
You want the enduser to know which rows are editable.
Matt Developer Support Engineer
In my scenario, I also need to make the entire row disabled, but the problem is I need to show Tooltip on each cell(editable or non-editable). The Tooltip gets disabled when IsEnabled = false. How to show the tooltip on a disabled cell ?
Hello Rajib,
Thank you for your post. I have been looking into it and I can suggest you use the Field's AllowEdit Proeprty instead of IsEditable one in order to be able to show ToolTips on non-editable Cells. You can also use the Editor's IsReadOnly Property, which doesn't block the tooltip neither.