WPF에서 ObservableCollection에 바인딩 된 listview가 있습니다.listview의 datatemplate에서 이벤트를 구독하는 방법
XAML : 나는 실제로 수신을 원하는 무엇
이<ListView Name="listView" DockPanel.Dock="Top" ItemsSource="{Binding Path=ListOfOldData}" SelectedItem="{Binding Path=SelectedOldData, Mode=TwoWay}" SelectionMode="Single">
<ListView.ContextMenu>
<ContextMenu>
<Button Content="Load" Command="{Binding Path=LoadCommand}" Name="loadButton" Height="23" Width="75" DockPanel.Dock="Left"/>
<!-- Is working just fine -->
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"
Text="{Binding Path=Name}" FontWeight="Bold"><TextBlock Text=" - " FontWeight="Normal"/><TextBlock Text="{Binding Path=UpdateDatum}" FontWeight="Normal"/></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
인을 두 번 클릭하여 선택 항목에. xaml의 텍스트 블록에 명령을 바인딩 할 수 없기 때문에 (0125) 그러나이 행사는 결코 받아 들여지지 않습니다! (코드에서 뒤에)
C 번호 :
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Console.WriteLine("MouseLeftButtonDown received!");
}
내가 잘못 뭐하는 거지? 어떻게 행사를받을 수 있습니까? Btw : 컨텍스트 메뉴의 명령이 잘 작동하고 있습니다.
업데이트 오류가 발생했습니다.> 잘못된 usercontrol에서 이벤트를 추가했습니다. 젠장. 너를 도청해서 미안해.
저에게는 효과가 없습니다. 이유는 모르지만 이벤트 처리기에서는 실행되지 않습니다. – basti
내가 가지고있는 것이 무엇인지 모르겠다. 컴파일하고 여기에서 작업하고있다. :) – MBen
내 listview가 확장기에 있기 때문에 문제가 될 가능성이 있습니까? – basti