This is a migrated thread and some comments may be shown as answers.

Set PropertyDefinition's EditorTemplate IsEnabled

1 Answer 111 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
rui
Top achievements
Rank 1
rui asked on 14 Dec 2017, 09:45 AM

Hello

I need change some PropertyDefinition's IsEnabled on run time,my solution is change PropertyDefinition's IsReadonly
public virtual void SetEnabled() 
{
            var squidProperties = this.FindChildByType<RadPropertyGrid>() as RadPropertyGrid;
            if (squidProperties == null)
                return;
            foreach (var item in squidProperties.PropertyDefinitions)
            {
                item.IsReadOnly = !_enable;
                if (item.HasNestedProperties) 
                {
                    foreach (var subItem in item.NestedProperties) 
                    {
                        subItem.IsReadOnly = !_enable;
                    }
                }
            }
  }

when the PropertyDefinition has  EditorTemplate, when  the EditorTemplate is single control  as the following code  it is works right

<telerik:PropertyDefinition.EditorTemplate>
              <DataTemplate>    
                         <telerik:RadWatermarkTextBox 
                                                             IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType=telerik:PropertyGridField}}"
                                                             Text="{Binding Filter}" />                                
                 </DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>

but  when the EditorTemplate is nested controls  as the following code,  it is works wrong

   <telerik:PropertyDefinition.EditorTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="auto" />
                                </Grid.ColumnDefinitions>
                                <telerik:RadWatermarkTextBox Grid.Column="0"
                                                             IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType=telerik:PropertyGridField}}"
                                                             Text="{Binding Filter}" />
                                <telerik:RadButton  />
                            </Grid>
                        </DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>

the RadWatermarkTextBox status is not readonly, when set the PropertyDefinition isreadonly true 

what is the reason for this?

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 19 Dec 2017, 09:06 AM
Hello rui,

I tried to reproduce the behavior you've described, but the IsReadOnly binding seems to work correctly at my end using the approach you've demonstrated.

I've attached the project I used in the process to my reply for your reference. Please have a look and let me know if I'm missing something of importance.

I look forward to your reply.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
PropertyGrid
Asked by
rui
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or