D
D
darked2018-08-28 16:05:29
WPF
darked, 2018-08-28 16:05:29

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>

Here is the model itself:
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();
                });
            }
        }

After filling the ListView, I double-click on all areas of the ListView and it works once in 50, on some lines, I just can’t understand what the problem is. What didn't you describe?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Yudakov, 2018-08-28
@AlexanderYudakov

https://stackoverflow.com/a/39065355

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question