Xamarin Community Toolkit MediaElement doesn't display videos - xamarin.forms

I created this ContentPage to display a video:
<ContentPage.Content>
<StackLayout>
<xct:MediaElement
Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
ShowsPlaybackControls="True" />
</StackLayout>
</ContentPage.Content>
But the result is a blank page without any content.

I added HeightRequest and WidthRequest and It's worked fine

Related

CarouselView swiping is Buggy

I'm relatively new to Xamarin Forms. I'm trying to have a view that allows me to swipe left/right between different pages with a page indicator at the bottom. I'm using CarouselView, as suggested by the internet, and it seems to work. But, the selected page is very buggy. Sometimes, swiping to the next page causes it to snap back to the previous page. Sometimes, it stays on the current page. Sometimes, it works correctly. I observe the same behavior on both Android and UWP. Although, it appears to be a little worse in UWP than Android.
It seems the index for the current page is getting mixed up somehow. Here is my XAML:
<ContentPage.Content>
<StackLayout>
<CarouselView x:Name="Pages" IndicatorView="{x:Reference ActivePageIndicator}">
<CarouselView.ItemsSource>
<x:Array Type="{x:Type ContentView}">
<views:TroubleshootingPage />
<views:StatusPage />
<views:ContactInfoPage />
</x:Array>
</CarouselView.ItemsSource>
<CarouselView.ItemTemplate>
<DataTemplate>
<ContentView Content="{Binding .}" />
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<IndicatorView
x:Name="ActivePageIndicator"
IndicatorColor="LightGray"
SelectedIndicatorColor="Green"
IndicatorSize="16"
IndicatorsShape="Circle"
HorizontalOptions="Center"
Margin="4"
/>
</StackLayout>
</ContentPage.Content>
I've tried using different types of views in the ItemsSource list. But, I still get the same effect.
Is there something I'm doing wrong? Something I'm missing? A bug in CarouselView?
Thanks.

Carousel Frame Wrongly Value Show When Scroll or Refresh the View on CardsView Plugin 2.8.1

i am Using CardsView plugin 2.8.1 .its Working fine on Emulator and simulator but while check on Deployment it Frame show the wrong value section on carousel and few second after it show properly
Same Issue on While Scroll the Content or Refresh View
<RefreshView>
<CollectionView x:Name="CollView">
<CollectionView.ItemTemplate>
<DataTemplate>
<cards:CarouselView>
<cards:CarouselView.ItemTemplate>
<DataTemplate>
<Frame/>
</DataTemplate>
</cards:CarouselView.ItemTemplate>
</cards:CarouselView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</StackLayout> ```

Xamarin.Forms CollectionView trigger event on Focus/Hover

I'm currently attempting to implement a Xamarin.Forms application which will be targeting Android TV. I have simplified my application to show the specific issue I'm having.
I have a collection of items which which I am displaying via a CollectionView. I am able to scroll around items inside this CollectionView using the D-Pad controls absolutely fine, as can be seen via this screenshot, where the "focussed"/"selected" item is visible if I make the layout bounds visible.
There is nothing available except the "ItemSelected" event on the CollectionView which only occurs on actually pressing enter. I have tried to add in "Focus" events to all the elements that make up this page and nothing gets triggered. I am unsure what exactly is being "focussed" upon here.
This is my page:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodels="clr-namespace:Channels.ViewModels"
x:Class="Channels.MainPage"
x:DataType="viewmodels:ChannelViewModel"
BackgroundColor="{DynamicResource BackgroundColour}">
<StackLayout Orientation="Vertical" Padding="10">
<Label Text="Selected Item" TextColor="White" Margin="0, 0, 10, 10"></Label>
<CollectionView ItemsSource="{Binding Data}">
<CollectionView.ItemsLayout>
<LinearItemsLayout ItemSpacing="5"></LinearItemsLayout>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="5" Spacing="5" BackgroundColor="Red">
<Label Text="Test Text" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" TextColor="White"></Label>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage>
I would like to know exactly what is getting focus here and if it is possible to do something like I have stated.
I haven't found many examples of Xamarin being used in terms of Android TV so it might not be possible to do things like this. I have also tried implementing the same code in .NET Maui and cannot find any events that might work here.
You could use the GestureRecognizers in the template to triger what you want to do when you selected the item or click on the item.
<Label>
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</Label.GestureRecognizers>
</Label>

How can I use partial views in Prism?

I have Prism 7.1 with Xamarin Forms 3.5. I can't get partial views to work correctly.
The consuming view has this up the top
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:converters="clr-namespace:MapManPrism.Converters"
x:Class="MapManPrism.Views.WelcomeWizardPage"
xmlns:mvvm="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
x:Name="wizard"
Title="Welcome" xmlns:cv="clr-namespace:PanCardView;assembly=PanCardView"
xmlns:cvi="clr-namespace:PanCardView.Controls;assembly=PanCardView" xmlns:views="clr-namespace:MapManPrism.Views">
As you can see I am giving the consuming page a name (wizard).
I then have a carouselview that has several views in it
<cv:CarouselView SelectedIndex="{Binding CurrentPage}" IsPanSwipeEnabled="false" IsUserInteractionEnabled="false">
<cv:CarouselView.ItemsSource>
<x:Array Type="{x:Type View}">
<ContentView Padding="10" Margin="10">
...
</ContentView>
<ContentView>
<Frame>
<views:PublisherDetails mvvm:ViewModelLocator.AutowirePartialView="{x:Reference wizard}"></views:PublisherDetails>
</Frame>
</ContentView>
In my app.xaml.cs I have this line
ViewModelLocationProvider.Register<PublisherDetails, PublisherDetailsViewModel>();
But I can't navigate to the consuming page when its set up like this. Removing "mvvm:ViewModelLocator.AutowirePartialView="{x:Reference wizard}"" makes it work, but obviously the view model for the partial view doesn't get wired up.
How can I fix this? Or, is there a way to manually connect the partial view's view model to see if that fixes it?

Carousel View is not showing in Windows Phone 8.1 in Xamarin.Forms

I have added "**CarouselView.FormsPlugin.Abstractions.dll**" file to WindowsPhone platform in VisualStudio.
And In PCL, I have added the code for CarouselView as follows :
<Grid Grid.Row="0">
<carusalView:CarouselViewControl Orientation="Horizontal"
InterPageSpacing="10"
Position="0"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
x:Name="CarosoulItem"
ShowIndicators="False"
IndicatorsShape="Circle"
PageIndicatorTintColor="Yellow"
CurrentPageIndicatorTintColor="Green">
<carusalView:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Image}" HeightRequest="200" Aspect="AspectFill"/>
</DataTemplate>
</carusalView:CarouselViewControl.ItemTemplate>
</carusalView:CarouselViewControl>
</Grid>
In Android and IOS, Here also I have downloaded Carousel from Nuget Package Manager. Carousel is working here.
But, For Windows also I did Same thing. Here its not showing Carousel.
****NOTE:I am not using UWP.
So, please anyone find the solution for this?

Resources