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

Can't add derived MediaPlayerElement in XAML #8973

Open
brabebhin opened this issue Oct 4, 2023 · 2 comments
Open

Can't add derived MediaPlayerElement in XAML #8973

brabebhin opened this issue Oct 4, 2023 · 2 comments
Labels
area-MediaPlayerElement bug Something isn't working team-Controls Issue for the Controls team

Comments

@brabebhin
Copy link

Describe the bug

The crash that occurred when deriving MediaPlayerElement has been fixed in the latest version, however, the derived MediaPlayerElement still can't be used inside XAML trees.

Steps to reproduce the bug

  1. Create a basic WinUI 3 with package support template using Visual Studio
  2. Replace MainWindow.xaml.cs with the following
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace App1
{
    /// <summary>
    /// An empty window that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
        }

        private void myButton_Click(object sender, RoutedEventArgs e)
        {            
            myButton.Content = "Clicked"
        }


    }

    public class Mpe: MediaPlayerElement
    {

    }
}
  1. Try to add the class to the XAML tree, like so
<Window
    x:Class="App1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
        <local:Mpe></local:Mpe>
    </StackPanel>
</Window>
  1. The following error will occur when running the app: WinRT originate error - 0x802B000A : 'Cannot add instance of type 'App1.Mpe' to a collection of type 'Microsoft.UI.Xaml.Controls.UIElementCollection'.

Expected behavior

It should be possible to add the derived MediaPlayerElement class inside an XAML tree

Screenshots

No response

NuGet package version

Windows App SDK 1.4.1: 1.4.230913002

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 22H2 (19045, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@brabebhin brabebhin changed the title Can't add derived MediaPlayerElement as Grid child Can't add derived MediaPlayerElement in XAML Oct 4, 2023
@bpulliam bpulliam transferred this issue from microsoft/WindowsAppSDK Oct 12, 2023
@bpulliam bpulliam added area-MediaPlayerElement team-Controls Issue for the Controls team labels Oct 12, 2023
@duncanmacmichael duncanmacmichael added the bug Something isn't working label Oct 23, 2023
@brabebhin
Copy link
Author

brabebhin commented Jan 25, 2024

Hi @codendone, @duncanmacmichael

Any progress on this?
Thanks.

@codendone
Copy link
Contributor

@brabebhin Unfortunately this issue is on the backlog with no timeline currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-MediaPlayerElement bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants