Skip to content

Add option to hide TimeStamp columns in EventWindow View menu #2247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 26, 2025

This PR adds the ability to hide/show TimeStamp columns in PerfView's Events page as requested in the issue. The implementation provides a new menu option in the View dropdown and properly handles the interaction with the existing timezone selection.

Changes Made

New Feature

  • Added "Show TimeStamp Columns" checkbox option to the View menu in EventWindow
  • When unchecked, hides both "TimeStamp (Trace Local)" and "TimeStamp (Current Machine)" columns
  • When timestamp columns are hidden, the "Show Local Time" option is grayed out (disabled)
  • When timestamp columns are shown, displays the appropriate column based on the current timezone preference

Implementation Details

  • EventWindow.xaml: Added new menu item with proper event handlers and x:Name attributes for programmatic access
  • EventWindow.xaml.cs:
    • Added DoShowTimeStampColumns() and DoHideTimeStampColumns() methods
    • Modified existing DoUseLocalTime() and DoUseOriginTime() to respect column visibility
    • Added initialization logic to restore saved preferences on startup
    • Added template copying logic for new window instances

User Experience

  • Default behavior: TimeStamp columns are visible (maintains backward compatibility)
  • Settings persistence: User preference is saved in App.UserConfigData["EventWindowShowTimeStampColumns"] and persists across sessions
  • New windows: When creating new event windows, the timestamp column visibility setting is inherited from the parent window

Menu Structure

View
├── Show TimeStamp Columns ✓ (new option)
└── Show Local Time ☐ (existing, gets disabled when timestamps hidden)

Example Usage

  1. Open PerfView Events page
  2. Go to View menu → Uncheck "Show TimeStamp Columns"
  3. Both timestamp columns disappear and "Show Local Time" becomes grayed out
  4. Setting persists when restarting PerfView
  5. Re-enable by checking "Show TimeStamp Columns" to restore timestamp display

This addresses the scenario where timestamp columns are redundant and provides users with a cleaner view when timestamp information is not needed.

Fixes #2246.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Provide the option to remove TimeStamp column from the Events page in PerfView Add option to hide TimeStamp columns in EventWindow View menu Jun 26, 2025
@Copilot Copilot AI requested a review from brianrob June 26, 2025 20:51
Copilot finished work on behalf of brianrob June 26, 2025 20:51
}
}
}

private void DoUseOriginTime(object sender, RoutedEventArgs e)
private void DoShowTimeStampColumns(object sender, RoutedEventArgs e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing there is a NullReferenceException thrown by this method:

System.NullReferenceException: Object reference not set to an instance of an object.
   at PerfView.EventWindow.DoShowTimeStampColumns(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.Controls.MenuItem.OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
   at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.SetValue(Object obj, XamlMember property, Object value)
   at System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
   at System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteEndMember()
   at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at PerfView.EventWindow..ctor(Window parent, PerfViewEventSource data)
   at PerfView.PerfViewEventSource.<>c__DisplayClass15_0.<Open>b__1()
   at PerfView.StatusBar.<>c__DisplayClass23_0.<EndWork>b__0()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the NullReferenceException by adding null checks in both DoShowTimeStampColumns and DoHideTimeStampColumns methods. The issue occurred because these event handlers were being triggered during XAML initialization when UI elements weren't fully constructed yet. Commit 6399125.

…ialization

Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
@Copilot Copilot AI requested a review from brianrob June 26, 2025 21:38
Copilot finished work on behalf of brianrob June 26, 2025 21:38
@brianrob
Copy link
Member

Copilot Post-Mortem:

  • This is another example where copilot is much better at "WPF-ing" than I am.
  • Thinking forward, I would like to be able to have copilot test its changes, which requires a Windows build and UI testing, but otherwise, this was quite simple.

@brianrob brianrob marked this pull request as ready for review June 26, 2025 23:50
Copy link
Member

@mconnew mconnew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@brianrob brianrob merged commit 415381c into main Jul 10, 2025
5 checks passed
@brianrob brianrob deleted the copilot/fix-2246 branch July 10, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide the option to remove TimeStamp column from the Events page in PerfView
4 participants