Hello
I'm doing a code reader which already works with the camera but I want it to work with a pocket PDA that has SCAN integrated
Any idea how I could do it? Will it only be with some permission or is the code different?
I just start with the apps and I do not fully understand their logic
how to make Qr code reader in pocket pda with android?
acr.userdialogs alerasync with mvvmcross
I am trying to get an alert message with the following code:
`
private readonly IUserDialogs _userDialogs;
public AddItemViewModel(IMvxNavigationService navigationService, IMvxLog log, IUserDialogs userdialog)
{
_navigationService = navigationService;
_log = log;
_userDialogs = userdialog;
}
//go back to homeViewModel and save new item
public IMvxAsyncCommand SaveNewItem => new MvxAsyncCommand(backToHVM);
private async Task backToHVM()
{
if (Name.Length == 0) //Cant have an empty name
{
//warn user
await _userDialogs.AlertAsync(new AlertConfig {
Title="Name is Required",
Message="",
OkText="Ok"
});
}
else
{
await _navigationService.Close(this, newItem);
}
}`
But as soon as I press the button witch uses the command. I get an System.NullReferenceException.
I thought maybe the _userDialogs variable is empty but that isnt true because if have de following line in my app.cs
Mvx.IoCProvider.RegisterSingleton<IUserDialogs>(() => UserDialogs.Instance);
I searched online but there is no documentation and I couldnt find any examples that worked in my case.
Would you know how to correctly implement a alertDialog or where my mistake lies.
Any help is much appreaciated.
How to navigate to page with ICommand the right way
I want to navigate to page, when user click on a button it fires OpenPageCommand but I can't navigate to view from ViewModel because it violates MVVM so what's the right way to do it?
HomePage.xaml
...
<Button ...
Text="Login"
Command="{Binding OpenPageCommand}"
CommandParameter="Login"/>
<Button ...
Text="SignUp"
Command="{Binding OpenPageCommand}"
CommandParameter="SignUp"/>
<Button ...
Text="Appointments"
Command="{Binding OpenPageCommand}"
CommandParameter="Appointments"/>
<Button ...
Command="{Binding OpenPageCommand}"
CommandParameter="FAQs"/>
<Button ...
Text="New Appointment"
Command="{Binding OpenPageCommand}"
CommandParameter="NewAppointment"/>
...
HomeViewModel.cs
public ICommand OpenPageCommand { get; set; }
public HomeViewModel()
{
OpenPage = new Command<string>((arg) => OpenPage(arg));
}
private async void OpenPage(string value)
{
switch (value)
{
case "Login":
await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
break;
case "SignUp":
await Application.Current.MainPage.Navigation.PushAsync(new SignUpPage());
break;
case "Appointments":
await Application.Current.MainPage.Navigation.PushAsync(new AppointmentsPage());
break;
case "FAQs":
await Application.Current.MainPage.Navigation.PushAsync(new FaqPage());
break;
case "NewAppointment":
await Application.Current.MainPage.Navigation.PushAsync(new NewAppointmentPage());
break;
default:
return;
}
}
Xamarin Cancel Window Close
Seems like this should be obvious but how do I capture when the user clicks the X button to close the window? I need to ask them if they are sure before allowing it.
Not sure it matters but this is for a Xamarin app running on Windows as UWP.
How does the TwoWay binding mode work?
I'm Confused about the behavior of the TwoWay
binding mode, if the source has the value of a
and the target has a value of b
, then what is priority of the evaluated value,
for example:
<Label x:Name="label"
Text="TEXT"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Slider x:Name="scaleSlider"
BindingContext="{x:Reference label}"
Grid.Row="1" Grid.Column="0"
Maximum="10"
Value="{Binding Scale, Mode=TwoWay}" />
the source has the priority which apply the value of 1.0 to the Value
property of the slider, which is the needed behavior..
and here:
<Label x:Name="label"
Text="TEXT"
Scale="{Binding Value, Source={x:Reference scaleSlider}, Mode=TwoWay}"/>
<Slider x:Name="scaleSlider"
Grid.Row="1" Grid.Column="0"
Maximum="10"/>
also the source has the priority, but this is not the needed behavior
Does the TwoWay
mode always starts from the source? is there a way to tweak this behavior to choose the starter source?
Sample ToDo - Downloaded - How do I execute
I have downloaded the sample ToDo List. There are many members in the folder. What member do I click to execute the sample?
Platform independent Foreground service
I'm creating a Foreground service in Android, I would like all the business logic, timers, http requests etc that are done to be in written in .NET rather than the c# wrapper around Android.
Is this possible? I know the service is platform specific but is there a way to do all the business logic of the service in .NET?
I want to do this as I'm a c#.net developer and it easy to stick with what I know.
How to get the length in seconds of a WAV file?
Hi guys, I have been trying to find out how to get the length of a wave file recording for both Android and iOS.
Can it be done in the PCL, or there are specific platform methods to get this length?
Facebook and Google login in Xamarin.Form
Hello, my name is Daniel, I'm from Uruguay and I'm currently working on my final year project. It is a Cross-Platform application for Android and iOS. At this moment we are in an advanced stage of development, in which we are trying to incorporate advanced functionalities with my partner Diego. One of them is to be able to enter the app by logging in via Google or Facebook. For this we find a lot of information in google and in the forum but it is not adapted to the project or it is old. What we find always applies to the android project and not to the pcl. We want from our xaml page to be able to enter as google or facebook users.
We are currently working on .Net Standard and Android SDK v8.1
Could someone help us or provide information?
Thank you.
Using Multiple Properties in Relative Layout Constraint Expressions on XAML
i want to use Height and Y property-
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BtnAllRegion, Property=Height+Y, Factor=1, Constant=10}"
Could someone help me how to create a ipa file from visual studio 2017 MAC
I am new to xamarin forms and need some guidance creating an inhouse app IPA file to host on our company portal
How Loaders will be aligned vertically center in iOS by using ACR.UserDialogs Package?
In Android by using ACR.User Dialogs loaders are aligned vertically center but when it comes to iOS loaders are not coming center(coming at top).Can anyone help me to resolve this?
Thank You
Context menu
public override bool CanPerform(Selector action, NSObject withSender)
{
if (action == new Selector("Action1") || action == new Selector("Action2") || action == new Selector("Action3"))
{
return true;
}
return false;
}
selector action not catch copy, lookup,share. this reason not customize context menu. The customized menu adds up after these menus.
is this bug? or any solution?
Native to Forms Navigation
Hello guys,
I don't know if this is the right forum to talk about native-forms but here it goes.
I have two apps, one in Xamarin.Native and another in Xamarin.Forms. Both are fully developed and operational. Now, the objective is to integrate the one in forms into the native one. For example, by pressing a button inside the Xamarin.Native app, I will enter a Xamarin.Forms page, for instance, the login page. I'm doing so with native forms. The thing is, the navigation inside the Forms app is done by affecting the MainPage property of Application:
MyPage page = new MyPage();
Application.Current.MainPage = page;
in iOS, for example, I can navigate to a forms page this way:
var mainPage = new MyPage().CreateViewController();
_navigation = new UINavigationController(mainPage);
but, when inside forms context, when I affect Application.Current.MainPage, nothing happens. Does anyone know what can I do to make this navigation work?
Imran_Idrees
How to use google android and IOS places API in xamarin forms to search places and set pins. Please tell me I want to search places and get latitude and longitude to create polygons. Is this possible?
Xamarin.Plugin.FilePicker
Hi all,
I am using the plugin mentioned in the title and getting quite frustrated with the following behavior.
I have a number of buttons the home screen which each have 2 functions. Quick press = play the video, press and hold = use file picker to choose which video file is associated to the button.
The problem I am having is that whichever button I long press and select video file for becomes the only updatable file path. For example, long press Button_1 and use the file picker to select Video_1. Short press on Button_1 plays the correctly chosen video file. Then when I long press on Button_2 and select a new video file, it updates Button_1, not 2. So frustrating.
To enable the short vs long press functionality, I used the Stoppable Timer solution from here: https://forums.xamarin.com/discussion/comment/149877/#Comment_149877
Code snippet is here:
[code]
region Button 1 Handler
public void OnButtonReleased_1()
{
if (stoppableTimer != null)
{
stoppableTimer.Stop();
}
string[] videoList = _videoFileManager.GetVideoPaths();
var page = new VideoPage(videoList[0]);
Navigation.PushAsync(page);
NavigationPage.SetHasNavigationBar(page, false);
}
public void OnButtonPressed_1()
{
if (stoppableTimer == null)
{
stoppableTimer = new StoppableTimer(TimeSpan.FromSeconds(2), VideoAdmin_1);
stoppableTimer.Start();
}
else
{
stoppableTimer.Start();
}
}
public async void VideoAdmin_1()
{
string[] options = new string[] { "Change Button Name", "Select a new Video" };
var selectedOption = await DisplayActionSheet("What would you like to do?", "Cancel", "", options);
if (selectedOption == options[0])
{
}
else if (selectedOption == options[1])
{
try
{
var file1 = await CrossFilePicker.Current.PickFile();
if (file1 == null)
return;
_videoFileManager.WriteVideoFiles(0, file1.FilePath);
stoppableTimer.Stop();
}
catch (Exception ex)
{
System.Console.WriteLine("Exception choosing file: " + ex.ToString());
}
}
}
#endregion
#region Button 2 Handler
public void OnButtonReleased_2()
{
if (stoppableTimer != null)
{
stoppableTimer.Stop();
}
string[] videoList = _videoFileManager.GetVideoPaths();
var page = new VideoPage(videoList[1]);
Navigation.PushAsync(page);
NavigationPage.SetHasNavigationBar(page, false);
}
public void OnButtonPressed_2()
{
if (stoppableTimer == null)
{
stoppableTimer = new StoppableTimer(TimeSpan.FromSeconds(2), VideoAdmin_2);
stoppableTimer.Start();
}
else
{
stoppableTimer.Start();
}
}
public async void VideoAdmin_2()
{
try
{
var file1 = await CrossFilePicker.Current.PickFile();
if (file1 == null)
return;
_videoFileManager.WriteVideoFiles(0, file1.FilePath);
stoppableTimer.Stop();
}
catch (Exception ex)
{
System.Console.WriteLine("Exception choosing file: " + ex.ToString());
}
}
#endregion
[/code]
Colorize one or several part(s) of a label's text
Hi,
I developed a page presenting some users. This last one is simply containing an entry and a listing.
I tried to colorize the users' informations matching with the text previously typed into the entry by using the Label property named FormattedText.
At first, the result was not so great and I discovered that using the FormattedText is actually displaying the informations in a very slowy way so I implemented a little hack that was simply splitting my string in X substrings and creating a label for each one of them that I would concat into an horizontal stacklayout.
The solution is working great on iOS, but on Android it's lagging a lot when I am scrolling down / up...
I am surprise to see that there is not control handling such basic behavior or maybe I missed them. Does anyone have an idea to implement a better solution ?
I thank you in advance and wish you a great weekend !
Best regards,
How to use checkbox control in xamarin.forms?
I Follow these steps but still facing the problem
Step 1: add Nuget package called Xlabs.form
step 2:CheckBox chk=new CheckBox()
{
checked=false;
}; in .cs
but still facing problems solution please?....
How to get an original image size?
Hi! I have the very basic case, but can't find elegant solution: need to know original image size for layout. But after loading an image to Image
view I get -1
value for its width and height.
Here's a code sample, what I'm trying:
var icon = new Image {
Source = ImageSource.FromFile("icon-edit.png")
};
// This will output -1 values for width and width request
Console.WriteLine("Width={0}, WidthRequest={1}", icon.Width, icon.WidthRequest);
// Adding to relative layout, won't work as expected! Icon's width is calculated as -1.
Children.Add(editIcon,
Constraint.RelativeToParent((parent) => (parent.Width - icon.Width) / 2),
Constraint.Constant(10)
);
In the example above icon should be centered horizontally and I could achieve that in some other way. But actually I'll need more sophisticated layout, that's why I need to know image width.
Adding ActivityIndicator to StackLayout show error in .cs file with red line: Argument 1: cannot con
Dear All.
Please help me in this regards. I get following error in .cs file when I add ActivityIndicator to Stacklayout.
It shows me red line with msg Argument 1: cannot not convert from .ActivityIndicator to Xamarin.Forms.Views.
Below is my code
ActivityIndicator ai = new ActivityIndicator() { IsVisible = true };
StackLayout sl = new StackLayout() {
Spacing = 0,
Margin = new Thickness(0, 0, 0, 0),
Padding = new Thickness(0, 0, 0, 0),
Children = { ai, periodgrid }
};
Thanks and best regards,