private void ActivateDesktopAlert(Shipment shipment) { RadDesktopAlert alert = new RadDesktopAlert(); var closedEventBinding = new EventBinding() { EventName = "Closed", RaiseOnHandledEvents = true}; BindingOperations.SetBinding( closedEventBinding, EventBinding.CommandProperty, new Binding() { Source = (this.DataContext as ViewModel).AlertClosedCommand }); var eventBindings = EventToCommandBehavior.GetEventBindings(alert); eventBindings.Add(closedEventBinding); alert.CanMove = false; switch (shipment.DeliveryType) { case DeliveryType.Truck: alert.Style = this.Resources["TruckStyle"] as Style; break; case DeliveryType.Train: alert.Style = this.Resources["TrainStyle"] as Style; break; case DeliveryType.Ship: alert.Style = this.Resources["ShipStyle"] as Style; break; } alert.DataContext = shipment; this.manager.ShowAlert(alert); }
private void OnSubmitDeliveryExecuted(object obj) { this.IsShipmentSending = true; var newShipment = new Shipment() { ID = id, CityFrom = this.SelectedCityFrom, CityTo = this.SelectedCityTo, DateOfArrival = (DateTime)this.SelectedDate, NumberOfItems = int.Parse(this.NumOfItems), DeliveryType = this.SelectedTransport}; this.Shipments.Add(newShipment); if (this.ActivateDesktopAlertAction != null) { this.ActivateDesktopAlertAction.Invoke(newShipment); } }