0
WPF에서 계층 적 트리 뷰가 있습니다. viewmodel을 사용하여 이벤트 바인딩을 위해 http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/을 사용합니다.TreeView의 상위 조상을 명령 매개 변수로 사용
트리 뷰에서 항목을 이중 클릭하면 항상 루트 유형을 명령 매개 변수로 전달하려고합니다.
예 :
..B
.... C
D ..E
내가 'A', 'B'또는 'C'내가 원하는 클릭
명령 매개 변수로 'A'. 'D'또는 'E'를 클릭하면 명령 매개 변수로 'D'를 원합니다. .. 내가 RelativeSource 바인딩해야 할 가정
<Setter Property="acb:CommandBehavior.Event" Value="MouseDoubleClick"/>
<Setter Property="acb:CommandBehavior.Command" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.SomeCommand}"/>
<Setter Property="acb:CommandBehavior.CommandParameter" Value="{Binding}"/>
, 나는 그것을 알아낼 수 없습니다
:이
는 지금까지이 항상 항목이 commandparameter로 클릭 전송 한 것입니다감사
미셸 내 지식
각 항목이 중첩 된 수준을 알고있는 경우 "바인딩 RelativeSource = {RelativeSource 모드 = FindAncestor, AncestorType = {x : Type TreeViewItem}, AncestorLevel = 2}, Path = DataContext.AProperty}"를 사용할 수 있습니다. AncestorLevel을 올바르게 설정해야합니다. – Phil