首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >双击可编辑TreeViewItem

双击可编辑TreeViewItem
EN

Stack Overflow用户
提问于 2014-06-04 06:35:57
回答 1查看 528关注 0票数 2
代码语言:javascript
复制
 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?)  

我正在WPF应用程序中创建一个TreeView。TreeViewItem是从数据库中获取的,当我双击TreeViewItem时,我想做可编辑的treeviewitem。但我得到了这个错误。我搜索了这个错误,但没有找到任何好的解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-04 06:41:57

在我看来,你已经从其他地方复制了一些代码。树视图在WPF中不可编辑。您已经复制了一些代码,无法找到类EditableTextBlock,因为它不存在于PresentationFramework中,而且您也没有添加在您复制的文章中引用的组件。通常,当您没有添加程序集引用和/或using语句来包含错误所引用的类时,就会得到此编译时错误。

我想成功地将它包含到项目中的第一步是了解它在您复制它的项目中是如何工作的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24030598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档