2
votes
 private void SetCurrentItemInEditMode(bool EditMode)
 {
        if (product_tree.SelectedItem is TreeViewItem)
        {
            TreeViewItem tvi = product_tree.SelectedItem as TreeViewItem;
            // Also make sure that the TreeViewItem
            // uses an EditableTextBlock as its header
            if (tvi.Header is EditableTextBlock)
            {
                EditableTextBlock etb = tvi.Header as EditableTextBlock;

                // Finally make sure that we are
                // allowed to edit the TextBlock
                if (etb.IsEditable)
                    etb.IsInEditMode = EditMode;
            }
        }
    }


error: The type or namespace name 'EditableTextBlock' could not be found (are you missing a using directive or an assembly reference?)  

i'm making a TreeView in WPF application. TreeViewItem is fetched from database and i want to make editable treeviewitem when i do double click on TreeViewItem. but i'm getting this error. i searched about this error but couldn't find any good solution

1

1 Answers

1
votes

It looks to me that you have copied some code from elsewhere. The tree view is not editable in WPF. You have copied some code and the class EditableTextBlock can't be found because it does not exist in the PresentationFramework and you haven't added the component referenced in the article you copied from. Generally you get this compile time error when you have not added an assembly reference and/or a using statement to include the class the error refers to.

I guess the first step to including it in your project successfully is to understand how it works in the project that you copied it from.