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

Update MediaElement Transport Controls for Windows #2329

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="ResourceDictionary.windows.xaml">
<LogicalName>ResourceDictionary.windows.xaml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace CommunityToolkit.Maui.Primitives;

sealed partial class CustomTransportControls : MediaTransportControls
{
public event EventHandler<EventArgs>? OnTemplateLoaded;
public AppBarButton FullScreenButton = new();
bool isFullScreen = false;

public CustomTransportControls()
{
this.DefaultStyleKey = typeof(CustomTransportControls);
}

protected override void OnApplyTemplate()
{
base.OnApplyTemplate();

var temp = GetTemplateChild("FullWindowButton") as AppBarButton;
if(temp is not null)
{
FullScreenButton = temp;
FullScreenButton.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
OnTemplateLoaded?.Invoke(this, EventArgs.Empty);
FullScreenButton.Click += FullScreenButton_Click;
}
}

void FullScreenButton_Click(object sender, RoutedEventArgs e)
{
if (isFullScreen)
{
FullScreenButton.Icon = new FontIcon { Glyph = "\uE740" };
isFullScreen = false;
}
else
{
FullScreenButton.Icon = new SymbolIcon(Symbol.BackToWindow);
isFullScreen = true;
}
}
}
Loading
Loading