Пример #1
0
        private void ContainersGridViewOnSelectionChanged(object sender, EventArgs eventArgs)
        {
            List <DockerContainerViewModel> containers = ContainersGridView
                                                         .SelectedItems
                                                         .Cast <DockerContainerViewModel>()
                                                         .ToList();
            DockerContainerListViewModel viewModel = (DockerContainerListViewModel)DataContext;

            viewModel.SelectedContainers.Clear();
            foreach (DockerContainerViewModel containerModel in containers)
            {
                viewModel.SelectedContainers.Add(containerModel);
            }
            DockerContainerViewModel container = (containers.Count == 1) ? containers[0] : null;

            viewModel.SelectedContainer = container;
            ContainerView.DataContext   = viewModel.SelectedContainer;
        }
Пример #2
0
        public DockerContainerListView()
        {
            XamlReader.Load(this);

            //todo: workaround for bug in Eto.Forms (probably related to https://github.com/picoe/Eto/issues/515)
            containersCollectionWatcher = new ObservableCollectionWatcher <DockerContainerViewModel>(ContainersGridView.Invalidate);

            DataContextChanged += (sender, args) =>
            {
                DockerContainerListViewModel viewModel = DataContext as DockerContainerListViewModel;
                containersCollectionWatcher.SetCollection(viewModel?.Containers);
            };

            IdCell.Binding      = Binding.Property <DockerContainerViewModel, string>(c => c.Id);
            ImageCell.Binding   = Binding.Property <DockerContainerViewModel, string>(c => c.Image);
            ImageIdCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.ImageId);
            CreatedCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.Created);
            StateCell.Binding   = Binding.Property <DockerContainerViewModel, string>(c => c.State);
            ContainersGridView.SelectionChanged += ContainersGridViewOnSelectionChanged;
        }