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

Programmatically clear text on edit?

1 Answer 61 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Karl B
Top achievements
Rank 1
Karl B asked on 05 Feb 2018, 06:07 PM

If my tree node text is empty I want to display special text to the user but I when the node is edited I want the text to be blank.  How can I achieve this?  Currently when hitting F2 I still have the "(Not Set)" text displayed.  

 

        <telerik:RadTreeView telerik:TextSearch.TextPath="DisplayName" 

 

public override string DisplayName
    {
    get
        {
        if ( string.IsNullOrEmpty ())
            {
            return "(Not Set)";
            }
 
        return this.m_displayName;               
        }
    set
        {
        this.m_displayName = value;
        }
    }

1 Answer, 1 is accepted

Sort by
0
Karl B
Top achievements
Rank 1
answered on 06 Feb 2018, 07:39 PM

I realized I already had the tools to achieve this

I had a IsEditing bool in my viewmodel-

<Style TargetType="telerik:RadTreeViewItem" BasedOn="{StaticResource RadTreeViewItemStyle}">
    <Setter Property="IsInEditMode" Value="{Binding IsEditing,Mode=TwoWay}"/>

And then in the DisplayName get we check for this flag-

if ( this.IsEditing || this.IsCategorySet() )
    {
    return this.m_displayName;
    }
 
return this.m_unsetCategoryname;

Now it will return an empty string when editing

 

Tags
TreeView
Asked by
Karl B
Top achievements
Rank 1
Answers by
Karl B
Top achievements
Rank 1
Share this question
or