Skip to content

Conversation

Copy link
Contributor

Copilot AI commented May 30, 2025

When a user double-clicks on a trace file in the main window, PerfView should automatically expand the first level of options for that trace file. However, the TreeView was not auto-expanding because the IsExpanded property binding was missing from the TreeView's ItemContainerStyle.

Root Cause

The data model (PerfViewTreeItem) correctly sets IsExpanded = true when files are opened (in PerfViewData.cs lines 535 and 10689), but the TreeView's ItemContainerStyle in MainWindow.xaml was missing the binding to connect this property to the UI:

<TreeView.ItemContainerStyle>
    <Style TargetType="TreeViewItem">
        <Setter Property="AutomationProperties.Name" Value="{Binding Name}" />
        <!-- Missing: IsExpanded binding -->
    </Style>
</TreeView.ItemContainerStyle>

Solution

Added the missing IsExpanded property binding to the TreeView's ItemContainerStyle:

<TreeView.ItemContainerStyle>
    <Style TargetType="TreeViewItem">
        <Setter Property="AutomationProperties.Name" Value="{Binding Name}" />
        <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
    </Style>
</TreeView.ItemContainerStyle>

This connects the data model's IsExpanded property to the TreeViewItem's IsExpanded property, enabling automatic expansion when trace files are opened.

Change Impact

  • Minimal: Only 1 line added, 0 lines removed
  • Non-breaking: No existing functionality is affected
  • Standard pattern: Uses standard WPF property binding approach

Fixes #2217.


💡 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 AI changed the title [WIP] Opening a Trace Does Not Expand the List of Options Fix TreeView auto-expansion when opening trace files May 30, 2025
Copilot AI requested a review from brianrob May 30, 2025 19:25
@brianrob
Copy link
Member

Copilot post-mortem:

  • I know very little about WPF, and so this would have been a heavier lift for me.
  • All I had to do was a bit of testing locally to see that this worked.

@brianrob brianrob marked this pull request as ready for review May 30, 2025 20:17
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:

Copy link
Collaborator

@marklio marklio left a comment

Choose a reason for hiding this comment

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

I was initially annoyed that I had to go try to discover the same things that Copilot did in order to fix it, but I remembered I could look at the session and see what it learned. This was super-helpful in confirming that PerfViewTreeItem has the IsExpanded property backed with an INotifyPropertyChanged implementation that seemed wired-up correctly. Still, I wish Copilot had a summary that included the info "The tree view is backed by PerfViewTreeItem objects that have an IsExpanded property on them"

@brianrob brianrob merged commit 1189425 into main Jun 5, 2025
5 checks passed
@brianrob brianrob deleted the copilot/fix-2217 branch June 5, 2025 00:08
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.

Opening a Trace Does Not Expand the List of Options

4 participants