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

WinUI 3.0 Alpha: ListView Issue #2154

Closed
goh-chunlin opened this issue Mar 24, 2020 · 5 comments
Closed

WinUI 3.0 Alpha: ListView Issue #2154

goh-chunlin opened this issue Mar 24, 2020 · 5 comments
Labels
team-Rendering Issue for the Rendering team

Comments

@goh-chunlin
Copy link

Describe the bug
In the following code, there is an exception saying "(Error CS1503) cannot convert from 'Microsoft.UI.Xaml.Controls.ListView' to 'Windows.UI.Xaml.UIElement'".

var _compositor = Window.Current.Compositor;
VisualExtensions.GetVisual(ImageList).Clip = _compositor.CreateInsetClip();

However, in fact, the ImageList is actually Windows.UI.Xaml.Controls.ListView, which should be inherting from Windows.UI.Xaml.UIElement.
image

So it is a bit confusing because XAML and code behind tell different story.

Expected behavior
The namespace of ListView in both XAML and code behind should be the same.

Version Info

NuGet package version:
NuGet: Microsoft.WinUI 3.0.0-alpha.200210.0
image

Windows 10 version Saw the problem?
Insider Build (xxxxx)
November 2019 Update (18363) Yes
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT
@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 24, 2020
@ranjeshj
Copy link
Contributor

@goh-chunlin Is this a build error or just what the editor is saying on hovering over ? In WinUI3 we are switching the namespaces from Windows to Microsoft, so both the Markup and Code should say Microsoft. This might be an issue with the Visual studio Xaml designer showing the incorrect type.

@ranjeshj ranjeshj added team-Markup Issue for the Markup team needs-author-feedback Asked author to supply more information. labels Mar 24, 2020
@goh-chunlin
Copy link
Author

goh-chunlin commented Mar 28, 2020

Hi @ranjeshj ,

I have cleaned and rebuilt the solution but the problem is still there.

The editor only shows correct namespace if I indicate the prefix, as shown in the code below.

<Page
    x:Class="Demo01.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Demo01"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:winui="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <winui:ListView x:Name="ImageList"></winui:ListView>
    </Grid>
</Page>

Thanks for your time attending to this.

@msft-github-bot msft-github-bot removed the needs-author-feedback Asked author to supply more information. label Mar 28, 2020
@ranjeshj ranjeshj added team-Rendering Issue for the Rendering team and removed team-Markup Issue for the Markup team labels Mar 29, 2020
@ranjeshj
Copy link
Contributor

@goh-chunlin You cannot mix Windows.UI.Xaml and Microsoft.UI.Xaml types in WinUI3. So using WUX.ListView will not work. The compositor might still be the system compositor which is expecting Windows types. @codendone Is there a way to make this work ?

@codendone
Copy link
Contributor

VisualExtensions.GetVisual() comes from the Windows Community Toolkit, which does not yet have a WinUI 3 compatible version. The current version expects a Windows.UI.Xaml element, which is why you're getting that error. A WinUI 3 version is currently in progress: see CommunityToolkit/WindowsCommunityToolkit#3106.

Until then, you can replace this VisualExtensions.GetVisual(ImageList) call with its implementation: ElementCompositionPreview.GetElementVisual(ImageList).

@goh-chunlin
Copy link
Author

Thanks for the help, @codendone

I think my doubts are well answered and I will wait for the updates. For now, I will proceed to close this Issue, @ranjeshj

@msft-github-bot msft-github-bot removed the needs-triage Issue needs to be triaged by the area owners label Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rendering Issue for the Rendering team
Projects
None yet
Development

No branches or pull requests

4 participants