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

IsReadOnly binding VM's property

1 Answer 35 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Ye HaoChen
Top achievements
Rank 1
Ye HaoChen asked on 24 Feb 2014, 10:06 AM
I bound IsReadOnly with VM's property.
Code like this, but it's not working.

DbIsReadOnly is VM's property.

<telerik:PropertyDefinition Binding="{Binding Path=Host,Mode=TwoWay}" GroupName="dbSquidPorperties" DisplayName="{DynamicResource IP}" IsReadOnly="{Binding DataContext.DbIsReadOnly,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"    OrderIndex="0"/>

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 27 Feb 2014, 02:30 PM
Hello,

PropertyDefinition derives from DependencyObject, so that it supports data binding. However, it does not derive from FrameworkElement, and it does not have DataContext. Moreover, it is not a visual element, so you cannot use ElementName and RelativeSource bindings. The only way to bind some of its properties is to expose the source explicitly. For instance:
<telerik:PropertyDefinition Binding="{Binding Path=Host,Mode=TwoWay}"GroupName="dbSquidPorperties" DisplayName="{DynamicResource IP}" IsReadOnly="{Binding DbIsReadOnly,Source={StaticResource MyViewModel}}"    OrderIndex="0"/>

Regards,
Ivan Ivanov
Telerik
Tags
PropertyGrid
Asked by
Ye HaoChen
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or