1
XmlDataProvider
에 바인딩 된 TreeView
의 항목에 WPF DelegateCommand
을 어떻게 추가 할 수 있습니까? MVVM 패턴과 Composite WPF를 사용하고 있는데 사용자가 TreeView
에있는 항목을 두 번 클릭 할 때이 명령을 호출하려고합니다.데이터 바인딩 된 항목의 명령에 명령을 추가하는 방법
I은 할 그 DataContext
XmlDataProvider
로 설정 XAML에서 정의 TreeView
:
<MenuItem Command="{Binding NewCommand}" Header="_New" />
: I 단순히 뷰 모델에서
DelegateCommand
바인딩 코드의 다른 부분
<TreeView
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ItemsSource="{Binding XPath=/SomeTopElement/*}">
<TreeView.Resources>
<HierarchicalDataTemplate
DataType="SomeElement"
ItemsSource="{Binding XPath=child::*}">
<TextBlock Text="{Binding [email protected]}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
위의 TreeView
으로 어떻게이 작업을 수행 할 수 있습니까?
또 다른 질문에 StackOverflow (http://stackoverflow.com/questions/926451/how-can-i-attach-two-attached-behaviors-to-one-xaml-element) 및 일반 첨부 된 동작 TreeView (http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx) –
모든 UIElement에 명령을 연결하는 방법 : http://www.japf.fr/?p=22 –
@emddudley : 예, 첫 번째 링크는 목록 상자에 이중 clic 명령을 추가하기 위해 프로젝트 중 하나에서 사용한 것이고 매우 잘 작동합니다 –