Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
How to style a grid field (XamDateTimeEditor) so its not always in edit mode?
posted

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>

    </Style>

 

                        <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

 

Parents
  • 17559
    Verified Answer
    posted

    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:Field.Settings>

                                        <igDP:FieldSettings EditorType="{x:Type igEditors:XamDateTimeEditor}">

                                            <igDP:FieldSettings.EditorStyle>

                                                <Style TargetType="{x:Type igEditors:XamDateTimeEditor}">

                                                    <Style.Resources>

                                                        <Style TargetType="{x:Type igEditors:XamMonthCalendar}">

                                                            <Setter Property="DisabledDaysOfWeek" Value="Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday" />

                                                        </Style>

                                                    </Style.Resources>

                                                </Style>

                                            </igDP:FieldSettings.EditorStyle>

                                        </igDP:FieldSettings>

                                    </igDP:Field.Settings>

                                </igDP:Field>

     

    If you have any further questions I will be glad to help.

Reply Children
No Data