Hi,
I have requirement where i need apply the security and make the forms as readonly.I writing a generic
logic for all our screens.I am using VisualTreeHelper in the base class to iterate all the control and make
IsReadOnly if possible otherwise IsEnabled=false. For the XamDataGrid i am able to set the FieldSettting
AllowEdit and it works fine. The problem is with the Custom CellValuePresenter.I am accessing the
CellValuePresenter in the XamDataGrid Loaded event and search all the control inside in it using VisualTreeHelper
and applying a binding to IsReadOnlyProperty or IsEnabledProperty.It finds the control and applys the binding
but still the user can edit the control.
Could you please suggest me the best way for dealing with CellValuePresenter?
Ramesh,
I suggest binding the IsEnabled or IsReadOnly properties of all your elements inside the custom CellValuePresenter to a property of the CellValuePresenter (for example the Tag property) so that when you set the CellValuePresenter's Tag property, all the controls inside will be disabled automatically through binding and you will not have to iterate through all of them with the tree helper.
The problem is if they use the Non ValueEditor in the CellValuePresenter it workn't work. Let's say they are
using the TextBox/Special Control and the Field AllowEdit is False in that case EditModeStarting Event
won't work.How do we handle this situation?
Thanks
Ramesh Babu.
So this works for all the other CellValuePresenters except the custom one? You should be setting IsEnabled/IsReadOnly to the editor in that cellvaluepresenter. If that is not working, you can try canceling the EditModeStarting event. Actually, you can do this for all the cellvaluepresenters, instead of iterating through all of them.
Please Can someone reply for this.