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

Bug: Make TargetType support abstract classes #26672

Open
mfkl opened this issue Dec 17, 2024 · 0 comments
Open

Bug: Make TargetType support abstract classes #26672

mfkl opened this issue Dec 17, 2024 · 0 comments
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@mfkl
Copy link
Contributor

mfkl commented Dec 17, 2024

Description

Describe the bug

Hi,

While trying to add support for MAUI WinUI in LibVLCSharp (videolan/libvlcsharp#370), I've ran into what I believe is a regression from standalone WinUI. Indeed this behavior is supported in other XAML/UI flavors so I believe it should also work in WinUI MAUI.

Given this style:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vlc="using:LibVLCSharp.Platforms.Windows">

    <Style TargetType="vlc:VideoViewBase">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="vlc:VideoViewBase">
                    <SwapChainPanel x:Name="SwapChainPanel" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

And this base class:

[TemplatePart(Name = PartSwapChainPanelName, Type = typeof(SwapChainPanel))]
public abstract class VideoViewBase : Control, IVideoView
{
/// stuff
}

This works fine in UWP, WinUI and Uno. But in WinUI for MAUI, I get the following error logs and stack trace:

Exception thrown at 0x00007FFE1316B699 (KernelBase.dll) in LibVLCSharp.MAUI.Sample.exe: WinRT originate error - 0x800F1000 : 'Cannot apply a Style with TargetType 'LibVLCSharp.Platforms.Windows.VideoViewBase' to an object of type 'Microsoft.UI.Xaml.Controls.Control'.'.
Microsoft.ui.xaml.dll!00007FFD09D843D2: 800F1000 - E_NER_INVALID_OPERATION
Exception thrown: 'System.Runtime.InteropServices.COMException' in WinRT.Runtime.dll
Exception thrown at 0x00007FFE1316B699 (KernelBase.dll) in LibVLCSharp.MAUI.Sample.exe: WinRT originate error - 0x800F1000 : 'No installed components were detected.

stack:

 	KernelBase.dll!00007ff95768b699()	Unknown
 	Microsoft.UI.Xaml.Controls.dll!00007ff8c616f5bf()	Unknown
 	Microsoft.UI.Xaml.Controls.dll!00007ff8c5d6d0b3()	Unknown
 	Microsoft.UI.Xaml.Controls.dll!00007ff8c5d82e9e()	Unknown
 	Microsoft.UI.Xaml.Controls.dll!00007ff8c5dc42c1()	Unknown
 	Microsoft.UI.Xaml.Controls.dll!00007ff8c5dd89a8()	Unknown
 	[Managed to Native Transition]	
>	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(WinRT.IObjectReference _obj, Windows.Foundation.Size availableSize) Line 30	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Windows.Foundation.Size availableSize) Line 673	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Windows.Foundation.Size availableSize) Line 678	C#
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(nint thisPtr, Windows.Foundation.Size availableSize, Windows.Foundation.Size* result) Line 33	C#

This looks like the same issue as CommunityToolkit/Windows#273.

Originally opened here microsoft/microsoft-ui-xaml#10228.

I can reproduce the error 90% of the time when running the sample app.

Steps to Reproduce

  1. Clone Maui winui videolan/libvlcsharp#370
  2. Run the sample without videolan/libvlcsharp@267bf18
  3. Observe native exception on start

Link to public reproduction project repository

videolan/libvlcsharp#370

Version with bug

9.0.21 SR2.1

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

Use a concrete class instead of an abstract class.

Relevant log output

@mfkl mfkl added the t/bug Something isn't working label Dec 17, 2024
@jfversluis jfversluis added the area-xaml XAML, CSS, Triggers, Behaviors label Dec 17, 2024
@jfversluis jfversluis added this to the .NET 9 SR3 milestone Dec 17, 2024
@jfversluis jfversluis added the s/triaged Issue has been reviewed label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants