- Is it possible to target an entire stylesheet base on platform for CSS?
- Is it possible to targe a specific style for a specific platform based on CSS?
Can i code for a Xamarin.forms css style sheet base on platform? Can i target a style sheet?
How to round off the corners of a Button and a StackLayout
Hello,
I'm actually making an application on Xamarin. I have created a Stacklayout with buttons inside. How can I round off the corners ? I use BorderRadius for the button but it doesn't work.
Thank you Image may be NSFW.
Clik here to view.
How to change BG color for ViewCell ContextActions
Hi guys,
Hope your doing great,
I created ListView with three Context Actions, here I want to set different background color for each MenuItem like below
Image may be NSFW.
Clik here to view.
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PureSale.Core.Views.OrdersListTemplate">
<Grid Padding="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackLayout Spacing="5">
<Label Text="{Binding Title}" FontAttributes="Bold" HorizontalOptions="StartAndExpand"/>
<Label Text="{Binding StartDate}" HorizontalOptions="StartAndExpand"/>
</StackLayout>
<Image Source="indicatorIconBlack.png" Grid.Column="1" HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand"/>
</Grid>
</ViewCell>
public partial class OrdersListTemplate : ViewCell {
public OrdersListTemplate(){
InitializeComponent();
var deleteAction = new MenuItem { Text = "Delete", StyleId = "labelRedStyle" };
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
deleteAction.Clicked += (sender, e) => {
};
var archiveAction = new MenuItem { Text = "Archive", IsDestructive = true};
archiveAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
archiveAction.Clicked += (sender, e) => {
};
var cancelAction = new MenuItem { Text = "Cancel" };
cancelAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
cancelAction.Clicked += (sender, e) => {
};
ContextActions.Add(cancelAction);
ContextActions.Add(archiveAction);
ContextActions.Add(deleteAction);
}
}
XAML
<ListView HasUnevenRows="true" ItemsSource="{Binding OrderItems}" ios:ListView.SeparatorStyle="FullWidth" SelectedItem="{Binding SelectedListItem}">
<ListView.ItemTemplate>
<DataTemplate>
<views:PartyListTemplate/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
How can I set StyledId for menu item, Please suggest me
Thanks in advance
Xamarin.Forms Speech to Text crashes on iPad iOS
Hi,
I have an app developed in Xamarin.Forms. I Used SpeechToText functionality in the app. It works fine on Android and iPhone, but on iPad it failed with following run time exception on first or second tap:
Hardware Model: iPad4,8
OS Version: iPhone OS 10.2.1 (14D27)
```
Application Specific Information:
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
Last Exception Backtrace:
0 CoreFoundation 0x000000018cddd1b8 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x000000018b81455c objc_exception_throw + 52
2 CoreFoundation 0x000000018cddd08c +[NSException raise:format:arguments:] + 100
3 AVFAudio 0x00000001a62a3300 AVAE_RaiseException(NSString*, ...) + 56
4 AVFAudio 0x00000001a6318abc AVAudioNodeImplBase::CreateRecordingTap(unsigned long, unsigned int, AVAudioFormat*, void (AVAudioPCMBuffer*, AVAudioTime*) block_pointer) + 268
5 AVFAudio 0x00000001a6316718 -[AVAudioNode installTapOnBus:bufferSize:format:block:] + 212
6 AgriSynciOS 0x00000001015d7588 wrapper_managed_to_native_ObjCRuntime_Messaging_objc_msgSend_intptr_intptr_System_nuint_uint_intptr_intptr (<unknown>:1)
7 AgriSynciOS 0x0000000101590788 AVFoundation_AVAudioNode_InstallTapOnBus_System_nuint_uint_AVFoundation_AVAudioFormat_AVFoundation_AVAudioNodeTapBlock (AVAudioNode.g.cs:118)
````
Below is the code (used with Dependencyservice):
` public class SpeechToTextImplementation : ISpeechToText
{
private Action _callback;
#region Private Variables
private AVAudioEngine AudioEngine;
private SFSpeechRecognizer SpeechRecognizer;
private SFSpeechAudioBufferRecognitionRequest LiveSpeechRequest;
private SFSpeechRecognitionTask RecognitionTask;
#endregion
public SpeechToTextImplementation()
{
}
public void InitializeProperties()
{
try
{
if (AudioEngine == null)
AudioEngine = new AVAudioEngine();
if (SpeechRecognizer == null)
SpeechRecognizer = new SFSpeechRecognizer();
if (LiveSpeechRequest == null)
LiveSpeechRequest = new SFSpeechAudioBufferRecognitionRequest();
}
catch (Exception ex)
{
LogController.LogError(ex.Message, ex);
}
}
public void Start(Action<EventArgsVoiceRecognition> handler)
{
_callback = handler;
AskPermission();
}
public void Stop()
{
CancelRecording();
}
void AskPermission()
{
try
{
// Request user authorization
SFSpeechRecognizer.RequestAuthorization((SFSpeechRecognizerAuthorizationStatus status) =>
{
// Take action based on status
switch (status)
{
case SFSpeechRecognizerAuthorizationStatus.Authorized:
InitializeProperties();
StartRecordingSession();
break;
case SFSpeechRecognizerAuthorizationStatus.Denied:
// User has declined speech recognition
break;
case SFSpeechRecognizerAuthorizationStatus.NotDetermined:
// Waiting on approval
break;
case SFSpeechRecognizerAuthorizationStatus.Restricted:
// The device is not permitted
break;
}
});
}
catch (Exception ex)
{
LogController.LogError("SpeechRecognition::AskPermission", ex);
}
}
public void StartRecordingSession()
{
try
{
//var format = new AVAudioFormat(AVAudioCommonFormat.PCMInt16, 44100, 2, false);
// Start recording
AudioEngine.InputNode.InstallTapOnBus(
bus: 0,
bufferSize: 1024,
format: AudioEngine.InputNode.GetBusOutputFormat(0),
tapBlock: (buffer, when) => LiveSpeechRequest?.Append(buffer)); ///Throw exception from here.
AudioEngine.Prepare();
NSError error;
AudioEngine.StartAndReturnError(out error);
//AudioEngine.MainMixerNode.
// Did recording start?
if (error != null)
{
return;
}
CheckAndStartReconition();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public void CheckAndStartReconition()
{
if (RecognitionTask?.State == SFSpeechRecognitionTaskState.Running)
{
CancelRecording();
}
StartVoiceRecognition();
}
public void StartVoiceRecognition()
{
try
{
RecognitionTask = SpeechRecognizer.
GetRecognitionTask(LiveSpeechRequest,
(SFSpeechRecognitionResult result, NSError err) =>
{
try
{
if (result == null)
{
CancelRecording();
return;
}
// Was there an error?
if (err != null)
{
CancelRecording();
return;
}
// Is this the final translation?
if (result != null && result.BestTranscription != null && result.BestTranscription.FormattedString != null)
{
Console.WriteLine("You said \"{0}\".", result.BestTranscription.FormattedString);
TextChanged(result.BestTranscription.FormattedString);
}
if (result.Final)
{
TextChanged(result.BestTranscription.FormattedString, true);
CancelRecording();
return;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
CancelRecording();
}
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public void StopRecording()
{
try
{
AudioEngine?.Stop();
LiveSpeechRequest?.EndAudio();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public void CancelRecording()
{
try
{
AudioEngine?.Stop();
RecognitionTask?.Cancel();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public void TextChanged(string text, bool isFinal = false)
{
// textChanged?.Invoke(this, new EventArgsVoiceRecognition(text, isFinal));
if (_callback != null)
_callback(new EventArgsVoiceRecognition(text, true));
}
}
`
Any thought on this?
LoginPage with FreshMVVM ?
Hello,
what is the best way to implement a Login page with FreshMVVM ?
Any sample or suggestion ?
Thank you
Marco
How to set custom font family using CSS in Xamarin ?
I'm trying to set custom font family using CSS file in Xamarin forms project. My custom font is 'Bodoni'.
I placed the respective font files in the android and ios project (MyApp.Mobile.App.Android/Assets/Bodoni.ttf for android) and (MyApp.Mobile.App.iOS/Resources/Bodoni.tff for IOS).
Those font files target its BuildAction as AndroidAsset for Android project and BundleResource for iOS project.
The CSS file is defined in the common project and declared in the App.xaml
.titleLabel {
font-family: Bodoni;
color: #960051;
}
The css file is well interpreted and my element (Label) contains the styleClass attribute with the 'titleLabel' value.
The color property works well but the font family does not change.
Are there any other manipulations to do to integrate my custom font ?
Note : When I try to target the the font files as AndroidResource, this error appear : invalid resource directory name: MyApp.Mobile.App.Android\obj\Debug\res assets "res assets".
Can you have a scrollview in a scrollview?
I have a carousel page that has 4 content pages. 2 of the pages require that i create a "lookup" entry box and brings up data as the user is typing. I'm doing this via a webservice call and populating the data into a grid thats visibility is controlled by a boolean.
What I need is the lookup grid to be in a scrollview with a fixed height so that i can scroll through the results. My issue is that all this content is already inside of a scrollview.
so I have something like this in a single content page. this one is kind of complicated.
<stacklayout> <grid/> <grid/> <scrollview> <stacklayout> <grid/> <grid> <scrollview> <Devexpress grid/> <scrollview/> <stacklayout/> <scrollview/> <grid/> <stacklayout/>
the devexpress grid displays and works the way i need it to but it will not scroll through its items.
Is this even possible?
Thanks in advance for any help!
How do I avoid different versions of an assembly in my App?
Hi,
In my solution I have several PCL-Projects that all use Nuget-Packages, some of them use the same packages. How can I make sure that all Projects use the same assembly versions? Especially when you update components, is there a way to update all projects at once?
If I have two versions on ony assembly in my App are both of them loaded at runtime?
I also have some warnings:
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
2> No way to resolve conflict between "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2> Consider app.config remapping of assembly "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.0.0" [] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Net.Http.dll] to solve conflict and get rid of warning.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1937,3): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file:
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1937,3): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
Thanks
Thomas
How to add an colored underline to a button on Xamarin.Forms Android
I am trying to add a colored underline to a Button
on Xamarin.Forms
. I made a custom renderer for iOS and got that working, but I can't seem to figure out a way to do it with a custom renderer on Android. The only thing i've found was adding a same color underline, but I want it to be a certain thickness and color. Anyone know how to handle this on Android?
Checkbox with Xamarin
Hi @all,
I have a question regarding a Windows Phone 8.1 Silverlight Project. I would like to use a checkbox in the app. Actually I found an implementation for checkbox in Xlabs, but unfortunately it seems that I am obviously not able to use it properly. When I set in xaml Checked=true then the marker will be displayed well, when checking or unchecking it again. But in default mode or when setting it to false then checking or unchecking won't display the marker in my case. In the Custom Renderer the properties are set accordingly but nothing is displayed. Does anyone have an idea or did anyone mentioned something liek this before? Any hint or advice might be helpful.
Thanks
Jérôme
How to select multiple images from gallery from both android and iOS device?
Hello,
I am working on xamarin.forms app. I am creating the app for android and iOS. I need to open the gallery and select multiple images from gallery of devices. How I can do this in xamarin.forms that can work for both android and iOS?
Regards,
Anand Dubey
Is Possible to use dll library which produce in ASP.Net targeting .net Framework 4.5.1 in Xamarin?
Hi,
First i apologize to my bad english.
I have start to build Xamarin project and i want use dll which produce from Asp.net Project. it is possible to add reference asp.net dll which targeting .net framework 4.5.1 in Xamarin.Forms? I have try to adding reference into my Xamarin.Forms project but always getting error like missing assembly and i adding manually that missing assembly but still it give me error when i try to deploy the app. is there way to use this dll in Xamarin?
Note : i can't access full code from asp.net dll.
Thanks.
MR.Gestures handles ALL touch gestures
With MR.Gestures you can handle the Tapping, Tapped, DoupleTapped, LongPressing, LongPressed, Panning, Panned, Swiped, Pinching, Pinched, Rotating and Rotated gestures on all layouts, cells, views and on the ContentPage.
The code can be as easy as
var box1 = new MR.Gestures.BoxView { Color = Color.Red };
box1.LongPressed += (s, e) => { Console.WriteLine("Code: Red LongPressed"); };
Or in XAML
<br /><mr:ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mr="clr-namespace:MR.Gestures;assembly=MR.Gestures"
x:Class="GestureSample.Views.ContentViewXaml"
Padding="50"
TappingCommand="{Binding TappingCommand}"
TappedCommand="{Binding TappedCommand}"
DoubleTappedCommand="{Binding DoubleTappedCommand}"
LongPressingCommand="{Binding LongPressingCommand}"
LongPressedCommand="{Binding LongPressedCommand}"
PanningCommand="{Binding PanningCommand}"
PannedCommand="{Binding PannedCommand}"
SwipedCommand="{Binding SwipedCommand}"
PinchingCommand="{Binding PinchingCommand}"
PinchedCommand="{Binding PinchedCommand}"
RotatingCommand="{Binding RotatingCommand}"
RotatedCommand="{Binding RotatedCommand}"
>
MR.Gestures is available via NuGet. More info on http://www.mrgestures.com/.
There is also a sample app available to download from https://github.com/MichaelRumpler/GestureSample. The GestureSample demonstrates how to use all the gestures with all Xamarin.Forms elements.
How to avoid showing keyboard when focusing EntryCell
Hi,
I have a Xamarin.forms project, I have a page with an EntryCell control, I want to avoid showing the keyboard when the EntryCell gets the focus since it is for scanning barcode labels, how can I achieve that? thanks.
How to do push notification
Hi Xamarin Forum,
Is there any reference for how to do a push notification in xamarin forms
Dividing Lines not consistently showing in Android (IOS working fine)
I m using a DataGrid in Xamarin forms ..but Its having a minor issues(Dividing Lines not consistently showing in Android (IOS working fine).
Plz help..thanks in Advance.
Remove listview selection background colour.
Hi, how to remove iOS listview selection background colour? Thanks in advance.
How to close keyboard while searching of app developed in Xamarin.Forms
Developing app in Xamarin forms We are facing some weird issue whereby searching app on an Android device after app open it shows keyboard for a second while splash screen load and then it closed when main activity page comes. Does anyone have the solution to it?
A lot of warnings appear in a new - empty Xamarin.Forms Xaml project
Hi,
I have created a new empty cross-platform Xamarin.Forms Xaml Project with the PCL project and an Android Project (I remove the IOS and WindowsPhone projects, because I don't need them).
As soon as I add the NuGet package XLabs.Forms, I get a lot of such warnings:
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteBluetoothIconDrawable. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteCastDrawable. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteCollapseGroupDrawable. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteConnectingDrawable. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteExpandGroupDrawable. Please check that your Nuget Package versions are compatible.
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1318,2): warning XA0106: Skipping MobileInventory.Droid.Resource.Attribute.mediaRouteOffDrawable. Please check that your Nuget Package versions are compatible.
There are a lot more but all of them of the same type (Please check that your Nuget Package versions are compatible).
I use the latest stable Xamarin.Forms and Xlabs.Forms packages.
Has anyone encountered the same? Can I ignore these warnings? What do they mean?
Regards,
Christian
How do I put a title bar on the top of my Androis/iOS app that remains visible at all times
Hi,
I want to put a title bar at the top of my app that remains visible regardless of which page the user has navigated to.
I have looked at the multi-pages, carousel, tabbed, master detail etc. but I have not found any examples of apps which place a title bar at the top of the app (containing menu and search) (see. image below).
Image may be NSFW.
Clik here to view.
What I really need is a hamburger menu or titlebar with hamburger menu and search button above a TabbedPage.
Is this possible?