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

How can I bind to a property on the PropertyGridFieldStyle?

1 Answer 124 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Magnus
Top achievements
Rank 2
Magnus asked on 26 Oct 2015, 10:27 PM
Hi! I know how to set a custom style for the field of a property grid but I cant figure out how I am supposed to make that style bound to anything that is relative to the specific PropertyDefinition of that field.
 
The PropertyGridField's PropertyDefinition is the default source the style's binding. The binding path of the PropertyDefinition might be "Communication.Timeout" but I want to bind the FontWeight property to "Communication.TimeoutProperty.Mode". How can this be done? 

 

Do I have to create a subclass of PropertyDefinition with my own dependency properties on to be able to do this?  

<telerik:RadPropertyGrid
    Name="PropertyGrid"
    IsGrouped="True"
    Item="{Binding SelectedItem}"
    EditMode="Single"
    RenderMode="Flat"                                 
    FieldStyle="{DynamicResource PropertyGridFieldStyle}"
    AutoGeneratePropertyDefinitions="False">
    <telerik:RadPropertyGrid.Resources>               
        <Style x:Key="PropertyGridFieldStyle"
               TargetType="{x:Type telerik:PropertyGridField}"
               BasedOn="{StaticResource PropertyGridFieldStyle}">                   
                    <Setter Property="FontWeight" Value="{Binding Path=???}"/>
        </Style>
    </telerik:RadPropertyGrid.Resources>
</telerik:RadPropertyGrid>

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 29 Oct 2015, 04:44 PM
Hi Magnus,

I am afraid, that it would not be possible to achieve such binding, as the DataContext of the PropertyGridField is the PropertyDefinition, which does not have such property defined. A possible resolution would be to use a RelativeSource in the TextWeight binding and bind it to an element, as per your requirements.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PropertyGrid
Asked by
Magnus
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Share this question
or