总结:WPF中模板需要绑定父级别的ViewModel该如何处理

     
                            
                                
                            
                            
                                
                                    
                                
                            
                        

其中、需要在代码

 Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Control_CodeAutoGeneration}}, Path=DataContext.RelayCommand}"   CommandParameter="ClassSelectionChanged"/>

处绑定的父级别,Control_CodeAutoGeneration是我自定义的控件的ViewModel里面的RelayCommand命令,通过如上传递可以调用到父级别的ViewModel的绑定属性或命令

你可能感兴趣的:(WPF)