Skip to content
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

Treeview - Changing root node and child node contents is not visually reflected in these nodes' displays. #10002

Open
johnt-star opened this issue Sep 21, 2024 · 0 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@johnt-star
Copy link

Describe the bug

Changing the contents of existing root and child nodes does not update the display of the nodes.

Note that collapsing and expanding child nodes will force a refresh and the display is now correct.

Steps to reproduce the bug

  1. Add a root node to a TreeView and set its contents to "Node 0"
  2. Add a child node to root node above and set it contents to "Child Node"
  3. Change the contents of the root node to "New Node Name"
  4. Change the contents of the child node to "New Child Name"

Problem: Root node still displays "Node 0" and child node still displays "Child Node".

Note that if you collapse and expand the child node, it will now display "New Child Name"

Expected behavior

The display for exisiting root nodes and child nodes should be updated when their contents are updated

Screenshots

This sample apps consists of a TextBlock on left, TreeView in middle with 3 root nodes and a child node, and a button on right to update contents of 1st root node and its child node.

image

Clicking Rename button shows that the TextBlock has read back the first root node contents and shows it to be the new content.
However, the 1st root node and its child node has not changed
image

Collapsing then expanding the 1st root node causes the child node to refresh and it now displays the new content
image

NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

Windows version

Windows 10 (21H2): Build 19044

Additional context

MainWindow.xaml

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
    <TextBlock Name="TextBlockContent"></TextBlock>
    <TreeView x:Name="TreeViewMain"></TreeView>
    <Button x:Name="myButton" Click="myButton_Click">Rename</Button>
</StackPanel>

MainWindow.xaml.cs
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();

        InitializeTreeView();
    }

    private void InitializeTreeView()
    {
        int iIdx;

        TreeViewNode treeViewNode;
        TreeViewNode treeViewChildNode;

        for (iIdx = 0; iIdx < 3; ++iIdx)
        {
            treeViewNode = new TreeViewNode()
            {
                Content = "Node " + iIdx.ToString(),
            };

            TreeViewMain.RootNodes.Add(treeViewNode);
        }
        
        treeViewNode = TreeViewMain.RootNodes[0];

        TextBlockContent.Text = treeViewNode.Content.ToString();

        treeViewChildNode = new TreeViewNode()
        {
            Content = "Child Node ",
        };

        treeViewNode.Children.Add(treeViewChildNode);
    }

    private void UpdateRootAndChildNode()
    {
        TreeViewNode treeViewNode;
        TreeViewNode treeViewChildNode;

        treeViewNode = TreeViewMain.RootNodes[0];

        treeViewNode.Content = "New Node Name";

        TextBlockContent.Text = treeViewNode.Content.ToString();

        treeViewChildNode = treeViewNode.Children[0];

        treeViewChildNode.Content = "New Child Name";

        TreeViewMain.UpdateLayout();
    }

    private void myButton_Click(object sender, RoutedEventArgs e)
    {
        UpdateRootAndChildNode();
    }

Also attaching project
TreeNodeSample.zip

@johnt-star johnt-star added the bug Something isn't working label Sep 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

1 participant