Converting WPF control to Mobile App( Xamarin.Foirm) in C# - c#

I am working on a Mobile App( Xamarin.Foirm). I have an WPF control that does animation that works, but now I am trying to convert it over to Mobile App( Xamarin.Frm) , so I can make a IOS, Android and UWP app that all uses the same base library.
However, the base library does not have a canvas nor a , So how do I add my svg to it as a path ?
<Viewbox>
<Path Name="path8" Canvas.Left="83.948" Canvas.Top="89.126" Width="971.099" Height="1047.555" Stretch="Fill" Fill="#FFE6F0FF" Data="M259.29 280.09c40.26-150 198.93-228.93 368.37-172.9c142.66 47.17 403.77 395 426 609.68 c21.09 203.81-200.17 404.81-536.78 418.9c-393.71 16.48-484.38-194.38-408.35-326.2C296 484.51 210.71 461 259.29 280.09z" d:IsLocked="True"/>
<Canvas/>
</Viewbox>
</ContentView.Content>
In visual Studios 2019 when you make an Mobile app (Xamarin.Forms) project you get 4 different projects. The 1st project is your base project( I do not know the real name for it) well it does not have a Canvas.
It does not have a path, viewbox nor canvas.
So how do I add my svgs and animation them, like I did with my WPF control?

Related

Xamarin.Forms Android 7.0 searchbar

The searchbar in forms doesn't appear on Android 7.0 devices, I am compiling with Android 6.0 not the latest version. The issue is apparently a google problem with calculating a height of the searchbar that results in a height of zero, thus no searchbar. I want to implement a searchbar size in XAML and only affect Android. Apparently, if I don't set the HeightRequest, Forms will use a default value or zero, so now the problem propagates to the other platforms. I read somewhere that if I set the HeightRequest to -1, it is invalid and Xamarin will calculate/default a height that makes sense and I can simply override the height for Android. I currently have this code in my XAML and it appears to work. I don't want to make a custom renderer, especially since the problem is apparently fixed in Android 7.1.
Anyone have a better solution?
Thanks
Alan
<SearchBar Text="{Binding Search}" Placeholder="Search order list" SearchCommand="{Binding SearchCommand}" >
<SearchBar.HeightRequest>
<OnPlatform x:TypeArguments="x:Double"
iOS="-1.0"
Android="40.0"
WinPhone="-1">
</OnPlatform>
</SearchBar.HeightRequest>
</SearchBar>

Xamarin Android - Gif in WebView is displayed blank

I got an issue while trying to display a gif for my UI.
When the app is launched, the .gif file is correctly loaded (if i change the path, a loading error occure) but the webView is displayed blank.
Android version : marshmallow 6.0 API lvl 23
the "ship_sea.gif" is currently located in Assets Folder, with "Android Asset" in build action.
the axml:
<WebView
android:id="#+id/myWebGIF"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp" />
the .cs :
WebView webGif = FindViewById<WebView>(Resource.Id.myWebGIF);
webGif.LoadUrl(string.Format("file:///android_asset/ship_sea.gif"));
Why is this not working? It is really simple and I can't figure out what is the problem.
Could it be the device as this post suggests (NVIDIA Shield Tablet K1)?
Ok guys, here is the answer :
Be sure that your canvas is the same size as your gif.
In my case, i had a particular large gif, and the only part rendered in my canvas was the top-left (a blank part).
The default background color for a webView is white, so it resulted in a blank view.
Problem solved : there was no error, just wrong interpretation of the problem.

How to play audio in the background of a UWP

I created a media player app using UWP for Windows 10. Currently I cannot play any audio in the background, when I minimize my media player window the audio stops playing and resumes when I maximize the window. This is my media element XAML code I used:
<MediaElement x:Name="PlayerElement" Height="532" Width="829"
AreTransportControlsEnabled="True" Stretch="Uniform" HorizontalAlignment="Center"
VerticalAlignment="Center" PosterSource="/Images/Logo3.png"
AutoPlay="True" MediaEnded="PlayNewSong" Margin="0,0,-9,0" AudioCategory="BackgroundCapableMedia"/>
I thought the AudioCategory property would solve my problem, but unfortunately it doesn't. Any help would be appreciated.
Check this official sample collection from microsoft WindowsUniversalSamples
You can pull BackgroundMediaPlayback folder for sample project you need.

Windows 8.1 XAML - LayoutTransform

I'm trying to use the LayoutTransform property to rotate some text 90 degrees in a windows 8.1/VS2013 template.
I am aware LayoutTransform is not in WinRT XAML so I followed the instructions on igrali's blog for using Layout transform in Windows 8 WinRT XAML but visual studio keeps saying:
'The name Layout Transformer" does not exist in the namespace
"using:Transforming.Common.'
Is this because I need to do something differently due to the changes in windows 8.1?
Joe
Thanks everyone for the suggestions. I found out how to do it eventually. I just had to make sure I had the correct name spaces above the style in app.xaml and mainpage.xaml. I just copied the namespace for common already included in the template into app.xaml.
maybe you can try this:
<TextBlock Text="Sample Text">
<TextBlock.RenderTransform>
<RotateTransform Angle="90"/>
</TextBlock.RenderTransform>
</TextBlock>

Implement Flick Gesture via GestureService from Windows Phone 8

I'm working on a Windows Phone 8 app. This app will allow a user to flick a panel up. I want this to work very similarly to the way the lock screen works. When the user 'flicks' the panel up, I want it to automatically, move up accordingly. Does anyone know how to do this? Currently, I have the following:
<Grid x:Name="myGrid" Background="Peru" VerticalAlignment="Stretch">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener x:Name="myGridGestureListener" DragStarted="myGridGestureListener_DragStarted" DragDelta="myGridGestureListener_DragDelta" DragCompleted="myGridGestureListener_DragCompleted" Flick="myGridGestureListener_Flick" />
</toolkit:GestureService.GestureListener>
<Grid.RenderTransform>
<TranslateTransform x:Name="bannerGridTransform" Y="5000" />
</Grid.RenderTransform>
</Grid>
private void myGridGestureListener_Flick(object sender, FlickGestureEventArgs e)
{
if (e.Direction == System.Windows.Controls.Orientation.Vertical)
{
}
}
For the life of me, I can't figure out how to get myGrid to smoothly react to the flick gesture accordingly. I figured someone would have already implemented this, however, apparently, I'm wrong.
Thank you!
Gesture Listener is deprecated in Windows Phone 8. When you download the latest toolkit source. It contains a sample toolkit app for window phone 8. When you click the gestures, it throws a dialog which says
The GestureListener is now obsolete in windows phone 8, as the built
in manipulation and gesture events now have functional parity with it.
This sample and the sample code demonstrated how to use the
manipulation and gesture events for purposes for which one previously
would have used the GestureListener
If someone need to implement gestures in Windows Phone 8 - look at this https://github.com/PedroLamas/WPtoolkit/blob/master/PhoneToolkitSample8/Samples/GestureSample.xaml.cs
Unfortunately this isn't as trivial as a couple of lines of code on SO since you have to account for the pan while you are holding down the screen and the flick which needs to seamlessly continue on from the pan when the user lifts their finger. A great example of this is actually a darts game since you want the dart to move while you are dragging and then fly off when you release (the flick).
You can find a great example with source code at http://windowsphone7developerguide.blograby.com/darts-gesture-listener-flick-gesture/
You dont need to use toolkit gesture listener anymore. You can use in built manipulation events. Here is the sample:-
http://phone.codeplex.com/SourceControl/latest#PhoneToolkitSample8/Samples/GestureSample.xaml.cs

Categories