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

Unexpected items were obtained in a subclass of ItemsControl #9646

Closed
GochenRyan opened this issue May 20, 2024 · 5 comments
Closed

Unexpected items were obtained in a subclass of ItemsControl #9646

GochenRyan opened this issue May 20, 2024 · 5 comments
Labels
area-Lists ListView, GridView, ListBox, etc bug Something isn't working team-Controls Issue for the Controls team

Comments

@GochenRyan
Copy link

GochenRyan commented May 20, 2024

Describe the bug

I wrote a RootDockControl subclass of ItemsControl. But when I pass DocumentDock (its VisibleDockables) to it through binding, what it gets is Document (DocumentDock's VisibleDockables).

Steps to reproduce the bug

  1. Clone https://github.com/GochenRyan/WinUISample
  2. Checkout commit a2089d3cdddd586a5eddff456d304fc3672aca02
  3. Set Layout as startup project
  4. insert a break point at https://github.com/GochenRyan/WinUISample/blob/a2089d3cdddd586a5eddff456d304fc3672aca02/WinUISample/Layout/Controls/RootDockControl.cs#L23
  5. Run
Snipaste_2024-05-20_23-58-57

Expected behavior

The item should be DocumentDock

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.3: 1.5.240428000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@GochenRyan GochenRyan added the bug Something isn't working label May 20, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label May 20, 2024
@GochenRyan
Copy link
Author

I tested it to be an ownerType issue. I get the result I want when the ownerType of VisibleDockablesProperty is DocumentDock. Is there a good way to handle the ownerType of VisibleDockablesProperty in the inheritance chain?

@codendone codendone added area-Lists ListView, GridView, ListBox, etc team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jun 7, 2024
@ranjeshj ranjeshj added the needs-author-feedback Asked author to supply more information. label Jun 28, 2024
@ranjeshj
Copy link
Contributor

@GochenRyan I'm having trouble understanding the issue. can you explain a bit more/provide a repro project that is scoped to the problem you are facing?

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Jul 2, 2024
@GochenRyan
Copy link
Author

@ranjeshj
I want to use the ContentTemplateSelector of ContentControl and the ItemTemplateSelector of ItemsControl to generate the corresponding custom controls step by step according to the node tree of xaml here:

<local1:DockControl>
    <models:RootDock>
        <models:RootDock.VisibleDockables>
            <models:DocumentDock>
                <models:DocumentDock.VisibleDockables>
                    <models:Document x:Name="Document1" Title="Program.cs">
                        <TextBlock Text="{Binding Title}"/>
                    </models:Document>
                    <!--<models:Document x:Name="Document2" Title="App.axaml">
                        <TextBlock Text="{Binding Title}"/>
                    </models:Document>-->
                </models:DocumentDock.VisibleDockables>
            </models:DocumentDock>
        </models:RootDock.VisibleDockables>
    </models:RootDock>
</local1:DockControl>

When creating a RootDockControl, its Items are not just the next level nodes.

@GochenRyan
Copy link
Author

@ranjeshj Actually I have a solution. I created a new branch fix-containerdp and fixed this issue in commit 9b43b77802fdb0e097ce09c8f9e7aeefe27b43f8. In short, by putting the container dependency property at the last level of the inheritance chain. But I don't know why the container dependency property needs to be handled specially.

@GochenRyan
Copy link
Author

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Jul 9, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Lists ListView, GridView, ListBox, etc bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants