private void OnSegmentClick(object sender, MouseButtonEventArgs e) { FrameworkElement source = e.Source as FrameworkElement; ISegment segment = source?.DataContext as ISegment; segment.Activate(); }