private static void NodesControl_PropertyChanged(object sender, ConnectionViewModel viewModel, string propertyName)
        {
            var nodesControl = (ConnectionsControl)sender;

            if (propertyName == nameof(ConnectionViewModel.IsSelected) && viewModel.IsSelected)
            {
                Reselect(nodesControl, viewModel);
            }
        }
Exemple #2
0
 public static IEnumerable <ConnectionViewModel> Build(INode node, int delay = 0, params INode[] nodes)
 {
     foreach (var n in nodes)
     {
         var conn = new ConnectionViewModel(node, n)
         {
             Delay = delay
         };
         yield return(conn);
     }
 }
        private static void Reselect(ConnectionsControl connectionsControl, ConnectionViewModel viewModel)
        {
            foreach (var item in connectionsControl.Items)
            {
                if (viewModel != ((ConnectionViewModel)item))
                {
                    (item as ConnectionViewModel).IsSelected = false;
                }
            }

            connectionsControl.Dispatcher.InvokeAsync(() => connectionsControl.SelectedObject = viewModel,
                                                      System.Windows.Threading.DispatcherPriority.Background, default);
        }