Answer the question
In order to leave comments, you need to log in
WPF ListView double click handler not working right?
Good time of the day.
The main form has a ListView that displays a list of records from the ViewModel:
<Window.DataContext>
<vmMain:VM_Main/>
</Window.DataContext>
.....
<ListView Grid.Column="0" Name="ProjectsList" ItemsSource="{Binding Path=Projects}"
SelectedItem="{Binding SelectedProject , Mode=TwoWay}">
<ListView.InputBindings>
<MouseBinding Command="{Binding Path=OpenProject}" MouseAction="LeftDoubleClick" />
</ListView.InputBindings>
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="№ Заказа" DisplayMemberBinding="{Binding Path=Number}"></GridViewColumn>
<GridViewColumn Header="КД" Width="170" DisplayMemberBinding="{Binding Path=KD}"></GridViewColumn>
<GridViewColumn Header="Наименование" Width="500" DisplayMemberBinding="{Binding Path=Name}"></GridViewColumn>
<GridViewColumn Header="Примечания" Width="200" DisplayMemberBinding="{Binding Path=Notes}"></GridViewColumn>
<GridViewColumn Header="Срок изготовления" Width="200" DisplayMemberBinding="{Binding Path=ProductionDate}"></GridViewColumn>
<GridViewColumn Header="Исполнитель" Width="300" DisplayMemberBinding="{Binding Path=Implementers, ValidatesOnExceptions=False, Converter={StaticResource ImplementerConverter}}"></GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
public class VM_Main : VM_Base
{
private VM_Project _selectedProject;
public VM_Main()
{
LoadProjects();
}
public ObservableCollection<VM_Project> Projects { get; set; } = new ObservableCollection<VM_Project>();
public ICommand OpenProject
{
get
{
return new DelegateCommand(obj =>
{
VM_Project vProject = SelectedProject;
ProjectInfoView view = new ProjectInfoView();
view.DataContext = vProject;
view.ShowDialog();
});
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question