I am using following style to set DisabledDaysOfWeek on a xamdatetimeeditor for one of the columns in my xamdatagrid.
<Style x:Key="MyStyle" TargetType="{x:Type DataPresenter:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataPresenter:CellValuePresenter}">
<Editors:XamDateTimeEditor Value="{TemplateBinding Value}">
<Editors:XamDateTimeEditor.Resources>
<Style TargetType="{x:Type Editors:XamMonthCalendar}">
<Setter Property="DisabledDaysOfWeek" Value="Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday" />
</Style>
</Editors:XamDateTimeEditor.Resources>
</Editors:XamDateTimeEditor>
</ControlTemplate>
</Setter.Value>
</Setter>
<igDP:Field Name="StartDate" Width="100" Label="Start Date" >
<igDP:Field.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource MyStyle}" />
</igDP:Field.Settings>
</igDP:Field>
This works great with one exception. When I disallow edit mode using:
MyGrid.FieldLayouts[0].FieldSettings.AllowEdit = false;
that column is still editable.
How should I style the field so its not editable when edit is not allowed, and when edit is allowed some of the week days are disabled?
Thank you
Hello Alexey,
I have looked at your code and I believe that the reason the cells are still editable after setting AllowEdit=false is because when you style the CellValuePresenter you retemplate the whole properties that it provides, so you have lost the AllowEdit functionality. You can work around this by styling only the XamDateTimeEditor. You can try this:
<igDP:Field Name="StartDate">
<igDP:FieldSettings EditorType="{x:Type igEditors:XamDateTimeEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamDateTimeEditor}">
<Style.Resources>
<Style TargetType="{x:Type igEditors:XamMonthCalendar}">
</Style.Resources>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
If you have any further questions I will be glad to help.
That works. Thank you!