I am creating a custom transport controls. In that, I have added an AppBarButton. To change the visibility of that I have created a Property for it, but for some reason, it doesn't work. The AppBarButton is always visible.
Code of the Property
//To change Visibility for CompactOverlayButton
public bool IsCompactOverlayButtonVisible
{
get
{
return compactOverlayButton != null && compactOverlayButton.Visibility == Visibility.Visible;
}
set
{
if (compactOverlayButton != null) //To neglect the Visibility check before the Template has been applied
{
compactOverlayButton.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
}
}
}
So I started debugging it. I can't find any error in the C# part, so I set Visibility="Collapsed"
for AppBarButton
in the XAML part. I am surprised, Even though I set Visibility="Collapsed"
the AppBarButton
is still visible.
Here is my code in XAML part
<AppBarButton x:Name='CompactOverlayButton'
Style='{StaticResource AppBarButtonStyle}'
MediaTransportControlsHelper.DropoutOrder='17' Visibility="Collapsed">
<AppBarButton.Icon>
<FontIcon Glyph=""/>
</AppBarButton.Icon>
</AppBarButton>
Update:
I found out the line of code which is causing it. It is from the C# part of the page where I have used this CustomMediaTransportControls
.
The Line which causing this is
var youtubeUrl = await YouTube.GetVideoUriAsync("QTYVJhy04rs", YouTubeQuality.Quality144P, videoQuality);
I have fixed the issue problem by setting CustomMediaControl.IsCompactOverlayButtonVisible = false;
after the above line of code. Still, I want to how the above line is affecting my program. The entire code the been included in the for reference part
For Reference:
Here is my entire code
- CustomMediaTransportControls.cs - Derived class from
MediaTransportControls
- MediaPlayerDictionary.xaml -
ResourceDictionary
- VideosPage.xaml - C# part of the page where I have used this
CustomMediaTransportControls
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…