| public class DataSource : DependencyObject |
| { |
| public List<DataSource> Children { get; set; } |
| public string Name { get; set; } |
| public DataSource() |
| { |
| Children = new List<DataSource>(); |
| } |
| } |
| <Window.Resources> |
| <local:DataSource x:Key="DataSource"> |
| <local:DataSource.Children> |
| <local:DataSource Name="1"> |
| <local:DataSource.Children> |
| <local:DataSource Name="2"> |
| <local:DataSource.Children> |
| <local:DataSource Name="3"> |
| <local:DataSource.Children> |
| <local:DataSource Name="4"/> |
| </local:DataSource.Children> |
| </local:DataSource> |
| </local:DataSource.Children> |
| </local:DataSource> |
| </local:DataSource.Children> |
| </local:DataSource> |
| </local:DataSource.Children> |
| </local:DataSource> |
| </Window.Resources> |
| <telerik:RadTreeView ItemsSource="{Binding Path=Children, Source={StaticResource DataSource}}" IsEditable="True"> |
| <telerik:RadTreeView.ItemTemplate> |
| <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"> |
| <TextBlock Text="{Binding Path=Name}"/> |
| </HierarchicalDataTemplate> |
| </telerik:RadTreeView.ItemTemplate> |
| <telerik:RadTreeView.ItemEditTemplate> |
| <DataTemplate> |
| <TextBox Text="{Binding Path=Name, Mode=TwoWay}"/> |
| </DataTemplate> |
| </telerik:RadTreeView.ItemEditTemplate> |
| </telerik:RadTreeView> |
Editing any node (by pressing F2) brings up the TextBox as it should. However that TextBox is empty and a BindingExpression error occurs (as visible in the output window):
System.Windows.Data Error: 40 : BindingExpression path error: 'Name' property not found on 'object' ''String' (HashCode=557208335)'. BindingExpression:Path=Name; DataItem='String' (HashCode=557208335); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')
Making the Name property a proper DependencyProperty has no effect. The DataItem seems to be getting changed. Curiously, if you change DataSource to NOT extend DependencyObject (ie make it just a CLR object), it works as expected. I cannot change my real hierarchy this way. Am I doing something wrong or should I log in PITS?
