TtT23
TtT23

Reputation: 7030

ContextMenu deselecting treeview item

When my contextmenu is popped up by right clicking on an item on the treeview, the selected row gets deselected but I want the selection to persist. How do I do this?

 <TreeView Name="ProgramTree" ItemsSource="{Binding ProgramItemCollection}">
      <TreeView.ContextMenu>
           <ContextMenu StaysOpen="True"> 
                <MenuItem Header="Open"/>
                <MenuItem Header="Check Syntax"/>
           </ContextMenu>
      </TreeView.ContextMenu>
      ...

Upvotes: 0

Views: 380

Answers (1)

Artiom
Artiom

Reputation: 7847

Actually it doesn't deselect your item. Probably you see your item with gray background. That's the color of the focused treeviewitem when it is inactive. You'll need to use styles to get rid of this. There was a similar question

Upvotes: 1

Related Questions