Context Menu Binding to Parent Window's Datacontext

后端 未结 2 1950
情深已故
情深已故 2020-12-16 07:10

I have a TreeListControl that binds to a collection in my VM. I also want to define the context menu inside the treelistcontrol having its header text bind to another string

2条回答
  •  悲&欢浪女
    2020-12-16 07:58

    Provide a name for your window and explicitly bind to it such as

    
    
    ...
    
     
    

    UPDATE

    Since the context menu is actually in its own window, binding is a bit trickier. Hence the best bet is to walk up the RelativeSource to the context's parent and pull the header text from there:

        
            
        
    
        ...
    
    
        
            
    
    
    
            
        
    

    Which for this context produces this

    enter image description here

提交回复
热议问题