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

wpf telerik user control databinding problem

1 Answer 100 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
OLeksiy
Top achievements
Rank 1
OLeksiy asked on 13 Jun 2013, 10:26 PM
Hi I am trying to create teleric propertygrid-based user control that contains a multiline textbox, but I can't configure data-bindig.
exactly i can't call set for property
public UserControl1()
   {
       InitializeComponent();
       this.DataContext = this;
       Rad.Item = new object() { };
   }
   public string longStringVal_
   {
       get
       {
           return (string)GetValue(longStringVal);
       }
       set
       {
           SetValue(longStringVal, value);
       }
   }
public static readonly DependencyProperty longStringVal =
   DependencyProperty.Register(
       "longStringVal_",
       typeof(string),
       typeof(TextBox)
   );

<Grid>
    <telerik:RadPropertyGrid x:Name="Rad" >
        <telerik:RadPropertyGrid.PropertyDefinitions>
            <telerik:PropertyDefinition DisplayName="LongStr" OrderIndex="-1" >
                <telerik:PropertyDefinition.EditorTemplate>
                    <DataTemplate>
                        <TextBox MinLines="3" MaxLines="3" 
                                 TextWrapping="Wrap"
                                 VerticalScrollBarVisibility="Visible"
                                 AcceptsReturn="true"
                                 x:Name="longStringValue"
                                 Text="{Binding Path = longStringVal_, Mode=TwoWay}"                                    
                                 />
                    </DataTemplate>
                </telerik:PropertyDefinition.EditorTemplate>
            </telerik:PropertyDefinition>
          </telerik:RadPropertyGrid.PropertyDefinitions>
    </telerik:RadPropertyGrid>
</Grid>
Any help is much appreciated!

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 18 Jun 2013, 03:35 PM
Hello,

The editors' DataContext is their parent PropertyGrid's Item. As the Object type does not have a longStringVal_ property your code results in a BindingExpressionPath error. The longStringVal_ is a member of the UserControl class, so that you should be using RelativeSource AncestorType binding to make it work.

Regards,
Ivan Ivanov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
OLeksiy
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or