CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

Catastrophic failure - Xaml Islands - MediaPlayerElement #287

Closed tonyhallett closed 3 years ago

tonyhallett commented 3 years ago

I have a WPF .Net Framework 4.7.2 project and I want to use the MediaPlayerElement and I do not want to create an MSIX package ( I have the visual C++ runtime installed ).
I have installed nuget Microsoft.Toolkit.Wpf.UI.Controls v6.1.2.

I looked at https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-standard-control-with-xaml-islands but did not create the UWP project.

Although the XamlApplication object isn't required for hosting a first-party UWP control, your app needs this object to support the full range of XAML Island scenarios, including hosting custom UWP controls. Therefore, we recommend that you always define a XamlApplication object in any solution in which you are using XAML Islands.

Besides, the WPf project cannot reference the UWP project https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/232

My xaml - app with single window

<Window x:Class="TrackNamesFromDiscogs.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TrackNamesFromDiscogs"
        xmlns:Controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
        mc:Ignorable="d"
        Title="MainWindow" Height="auto" Width="800">
    <Grid>

        <Controls:MediaPlayerElement x:Name="mediaPlayerElement" Source="https://mediaplatstorage1.blob.core.windows.net/windows-universal-samples-media/elephantsdream-clip-h264_sd-aac_eng-aac_spa-aac_eng_commentary-srt_eng-srt_por-srt_swe.mkv" AutoPlay="True" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AreTransportControlsEnabled="True" />
    </Grid>
</Window>

The error I receive is

"Catastrophic failure\r\n\r\nWindowsXamlManager and DesktopWindowXamlSource are supported for apps targeting Windows version 10.0.18226.0 and later. Please check either the application manifest or package manifest and ensure the MaxTestedVersion property is updated."

The solution https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/76#issuecomment-473943028 for this error message is for .NET Core I believe.

Note that - https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/232

.NET Framework doesn't support 3rd party scenarios, like referencing a UWP app project. I have sent a PR to fix the documentation.

Originally posted by @marb2000 in https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/232#issuecomment-595108076

The documentation fix still needs to be applied as the pull request was closed by @marb2000

If it is possible to achieve with WPF .Net Framework then please advise how.

Windows 10 Build Number: Version 1909, OS Build 18363.1082

Visual Studio



## Additional context
Add any other context about the problem here.
ghost commented 3 years ago

Hello tonyhallett, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

tonyhallett commented 3 years ago

Closing as I needed to add an app.manifest with. `

maxversiontested Id="10.0.18226.0"/> `