I want to create List View link any email list in Xamairn Forms for Android and iOS.
1) single select item:- on a single click of a cell, it should go inside that cell mins detail page of that single cell.
2) multi-select situation item:- if we click on cell for 1 or 2 seconds or Long press then can able to select multiple cells and to any operation like delete or move
how to create Single Select and multi select event in ListView using Xamarin forms
My list isn't rendering correctly my items!
private async void LoadMoreTickets()
{
listView.IsRefreshing = true;
var view = (ViewTicket)pickerViews.SelectedItem;
pageNumber++;
var ticketsList = await Api.GetTicketByView(view.Id, pageNumber);
//Tickets its a ObservableCollection and i dnt need to set the source again..
foreach (var item in ticketsList)
{
Tickets.Add(item);
}
listView.IsRefreshing = false;
}
I'm already making the method async, but my list doesn't render correctly, some fields dsnt appears...
someone have any idea why ?
Error java.lang.IllegalArgumentException: already added
Hi guys
I am new with xamarin
Getting an error like this :
Severity Code Description Project File Line Suppression State
Error java.lang.IllegalArgumentException: already added : Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; SmartTweet.Android
I update all the nuget packages, but the error still occur.
Anybody please suggest a solution
Thanks in advance...
iOS ListView item selected event is not firing. Xamarin Forms 2.4
Listview item selected event is not fired on iOS if ListView container has TapGestureRecognizer bound to it.
Reproduction steps:
1) create a container view (Stack, Grid, Frame, ContentViev ...)
2) add TapGestureRecognizer to the container view
3) add ListView inside the container and populate it with items
4) subscribe to ListView.ItemSelected event
5) Run app and click any item in the ListView
Expected result:
Item in the ListView is selected, ItemSelected event is fired
Actual result:
Item in the ListView is not selected, ItemSelected event is not fired
Xamarin Forms - ContentPage with SearchBar in the Navigation bar
Hi All,
Please help me how the search bar design, when i click search icon display search icon . please check attachments once.
authentication service is unavailable.
I am having an issue adding a apple developer account to visual studio Mac. this always gives an error "Error adding account - authentication service is unavailable." It was there at one time but I tried to remove and re-add it as a result of the signing certificates not syncing (not showing new certificates.).
I can remove and add the account in Xcode just fine, and it pulls up all of my certificates, just fine from Xcode.
I have also tried many other "solutions" to similar issues in syncing apple developer accounts in the forum to no avail
Deploying a Xamarin Forms Android app to emulator is taking a long time
I have a Xamarin Forms application, when I try to run the Android application, the application is taking a lot of time and progress is stuck in the middle.
The deployment hangs after starting the emulator,
Do you have any idea how this could be resolved?
Can not Deloy to VS Emulator?
I have create New Project, but I can not deloy to VS Emulator
My PC: i3-7100, RAM 8Gb, SSD 240G
MasterPage is overlapping NavigationBar in MasterDetailPage
My Problem is that my Masterpage is overlapping the NavigationBar and graying it out. I want the MasterPage to be beneath the navigation bar and only graying the detail out. How can I achieve this?
I am creating a MasterDetailPage like this:
var navPage = new NavigationPage() { };
MasterDetailPage masterDetailPage = new MasterDetailPage()
{
Master = MenuPage = BuildMenuPage(),
Detail = NavigationPage = navPage,
};
MainPage = masterDetailPage;
}
private Page BuildMenuPage()
{
return new MenuPage()
{
Title = "Menu",
Icon = "icon.png",
BackgroundColor = Color.Transparent
};
}
And navigation to a new Detail Page like this:
private async Task DefaultNavigation(Page page, string pageKey, object parameter, bool animated, string title)
{
MasterDetailPage mainPage = GetRootPageInstance(); //Singleton
NavigationPage _navPage = new NavigationPage(page);
NavigationPage.SetHasNavigationBar(_navPage, false);
await _navigation.PushAsync(_navPage, animated);
}
how to get the selectedItem inside Stackalyout in ListView ?
Hi Guys,
following senario,
I have a listview with ItemTemplate that is tied to a model, and within Listview I have several stack layouts (text, entrys, ..) and now if I am in an event of entry for example I would like to have my SelectedItem (Model) ,
how can i access the SelectedItem within the textchanged (entry), which in turn is in a listview?
How can I realize this?
thank you in advance
MovieService throwing an OutOfMemoryException
Hello! I'm trying to run Mosh's solution for the Netflix Roulette application. The MovieService keeps throwing an OutOfMemoryException every time I try to call the api. Does anyone know why this is happening?
`public partial class MoviesPage : ContentPage
{
private MovieService _service = new MovieService();
private BindableProperty IsSearchingProperty =
BindableProperty.Create("IsSearching", typeof(bool), typeof(MoviesPage), false);
public bool IsSearching
{
get { return (bool)GetValue(IsSearchingProperty); }
set { SetValue(IsSearchingProperty, value); }
}
public MoviesPage()
{
BindingContext = this;
InitializeComponent();
}
async void OnTextChanged(object sender, Xamarin.Forms.TextChangedEventArgs e)
{
if (e.NewTextValue == null || e.NewTextValue.Length < MovieService.MinSearchLength)
return;
await FindMovies(actor: e.NewTextValue);
}
async Task FindMovies(string actor)
{
try
{
IsSearching = true;
var movies = await _service.FindMoviesByActor(actor);
moviesListView.ItemsSource = movies;
moviesListView.IsVisible = movies.Any();
notFound.IsVisible = !moviesListView.IsVisible;
}
catch (Exception)
{
await DisplayAlert("Error", "Could not retrieve the list of movies.", "OK");
}
finally
{
IsSearching = false;
}
}
async void OnMovieSelected(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem == null)
return;
var movie = e.SelectedItem as Movie;
moviesListView.SelectedItem = null;
await Navigation.PushAsync(new MovieDetailsPage(movie));
}
}`
How to connect localhost of windows to iphone simulator in mac
I have xamarin.forms application for iOS and local database is created in sql server 2012 on windows 10,now i am trying to connect the localhost to the of windows to the iphone simulator.
i tried : Connecting through IP address of the windows Pc.
Connected mac and windows under same wifi.
Disabled firewall.
none of them worked.
The code i am trying to connect is:
private string Uri = "http://192.168.0.16:62271/";//Windows Ip address:localhost port number
private string GetDishesUrl = "api/DishDetails/GetDishDetails?id=5";
try
{
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(Uri);
var response = await httpClient.GetAsync(new Uri(Uri + GetDishesUrl));
var stringAsync = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var responseJson = stringAsync;
return JsonConvert.DeserializeObject<List<DishDetails>>(responseJson);
}
}
catch(Exception ex)
{
return null;
}
when i disabled firewall and trying to connect to mac then i am getting responseas null and also the exception also as null and in safari while giving Ip address along with GetDishesUrl getting as Bad Request-Invalid Hostname,How to acheive this local host connection? I already placed this this but i did get it to be worked.
ValueChanged event not working on click Xamarin forms
when Click on Slider then ValueChanged event is not getting trigger, but when I slide then this event is trigger
bellow is code
void OnSliderValueChanged(object sender, ValueChangedEventArgs e)
{
var newStep = Math.Round(e.NewValue / 0.5);
var a = (Slider)sender;
a.Value = newStep * 0.5;
}
The Slider is in ListView
Thanks,
PCL Storage System.NotImplementedException
Dear all,
I have installed PCLStorage nuget package to all of Portable Project, Android Project and iOS Project. Then i have get this piece of code from github page of PCL Storage:
public async Task PCLStorageSample() { IFolder rootFolder = FileSystem.Current.LocalStorage; IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists); IFile file = await folder.CreateFileAsync("answer.txt", CreationCollisionOption.ReplaceExisting); await file.WriteAllTextAsync("42"); }
Then called this method after click of a button and see this error:
System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation.
I searched a lot and can not find a solution. I need your helps.
Thanks,
Onur
How to set Password text to be dots instead of characters entered? C#
Basically:
this.sPassword = FindViewById<EditText>(Resource.Id.passwordInput);
Then
this.sPassword.MakeDottedText()....
Been trying to find out how to do this.
convert iOS to MAC
Hello,
I'm using the following class for auth in xamarin-ios, but I'm unable to use it xamarin-macos because SFSafariViewController, SFSafariViewControllerDelegate and UIViewController cannot be resolved.
Can anyone help me and tell me what classes should I use to convert this for mac support
public class PlatformWebView : SFSafariViewControllerDelegate, IBrowser
{
private SafariServices.SFSafariViewController m_Safari;
private readonly UIViewController r_Controller;
public PlatformWebView(UIViewController i_Controller)
{
r_Controller = i_Controller;
}
public override void DidFinish(SFSafariViewController i_Controller)
{
ActivityMediator.Instance.Send("UserCancel");
}
public Task<BrowserResult> InvokeAsync(BrowserOptions i_Options)
{
if (string.IsNullOrWhiteSpace(i_Options.StartUrl))
{
throw new ArgumentException("Missing StartUrl", nameof(i_Options));
}
if (string.IsNullOrWhiteSpace(i_Options.EndUrl))
{
throw new ArgumentException("Missing EndUrl", nameof(i_Options));
}
// must be able to wait for the intent to be finished to continue
// with setting the task result
TaskCompletionSource<BrowserResult> tcs = new TaskCompletionSource<BrowserResult>();
// create Safari controller
m_Safari = new SafariServices.SFSafariViewController(new NSUrl(i_Options.StartUrl));
m_Safari.Delegate = this;
ActivityMediator.MessageReceivedEventHandler callback = null;
callback = async (i_Response) =>
{
// remove handler
ActivityMediator.Instance.ActivityMessageReceived -= callback;
if (i_Response == "UserCancel")
{
tcs.SetResult(new BrowserResult
{
ResultType = BrowserResultType.UserCancel
});
}
else
{
// Close Safari
await m_Safari.DismissViewControllerAsync(true);
// set result
tcs.SetResult(new BrowserResult
{
Response = i_Response,
ResultType = BrowserResultType.Success
});
}
};
// attach handler
ActivityMediator.Instance.ActivityMessageReceived += callback;
// launch Safari
r_Controller.PresentViewController(m_Safari, true, null);
// need an intent to be triggered when browsing to the "io.identitymodel.native://callback"
// scheme/URI => CallbackInterceptorActivity
return tcs.Task;
}
}
public class ActivityMediator
{
public delegate void MessageReceivedEventHandler(string i_Message);
private static ActivityMediator s_Instance;
public static ActivityMediator Instance
{
get
{
if (s_Instance == null)
{
s_Instance = new ActivityMediator();
}
return s_Instance;
}
}
private ActivityMediator()
{
}
public event MessageReceivedEventHandler ActivityMessageReceived;
public void Send(string i_Response)
{
ActivityMessageReceived?.Invoke(i_Response);
}
}
How to make Round corner Entry Control Xamarin.Forms
I want to make Round corner Entry Control Xamarin.Forms,please some one help me in this issue
Multi-line text on buttons - how to get consistent across platforms?
When the Text property of a Button is set to text that contains more than one line (i.e. has a carriage return/linefeed in the middle), what gets displayed is different on each platform.
On iOS, only the first line is displayed.
On Android, all lines are displayed, but centered.
On Windows Phone, all lines are displayed, but left-justified.
This is easily reproduced, by using the FormsGallery sample and tweaking the code in the ButtonDemoPage as below:
Button button = new Button
{
Text = "This is a short line\r\nThis is a longer second line of text",
BorderWidth = 1,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
Is there any plan to make these behaviours consistent across platforms? If so, is there a timescale for this?
I know that I could write custom renderers to do this, but it seems such a basic thing that consistent behaviour should be built in, that I would expect this to appear in Xamarin.Forms itself at some point.
Thanks,
John H.
Show iframe video in full screen using Forms CustomRenderer webview on Android
In a Forms app we use a custom WebViewRenderer
in the .Droid
project to display html that contains videos embedded in <iframe>
.
I'm having trouble making these videos go into full screen when the user pushes the button to toggle full screen in the video player.
I'm trying to use WebChromeClient
, as per Xamarin's WebView full screen advise to toggle full screen mode. However, I'm not sure how to go about this. I have tried to port a Java implementation of WebChromeClient but I just get a blank screen after OnShowCustomView(View view, ICustomViewCallback callback)
has finished executing.
Here's the code (I think is relevant), let me know if I'm missing important pieces.
CustomRenderer for WebView:
public class MyWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
var activity = this.Context as Activity;
var view = activity.LayoutInflater.Inflate(Resource.Layout.fullScreenVideoLayouts, this, false);
ViewGroup videoViewLayout = (ViewGroup) view.FindViewById(Resource.Id.videoLayout);
View nonVideoLayout = view.FindViewById(Resource.Id.nonVideoLayout);
control.SetWebChromeClient( new WebViewWebChromeClient(nonVideoLayout, videoViewLayout));
}
}
Custom VideoEnabledWebChromeClient:
private class WebViewWebChromeClient : WebChromeClient
{
private View _activityNonVideoView;
private ViewGroup _activityVideoView;
private bool _isVideoFullscreen; // Indicates if the video is being displayed using a custom view (typically full-screen)
private FrameLayout _videoViewContainer;
private ICustomViewCallback _videoViewCallback;
public WebViewWebChromeClient() { }
public WebViewWebChromeClient(View view, ViewGroup formsViewGroup)
{
this._activityNonVideoView = view;
this._activityVideoView = formsViewGroup;
}
public override void OnShowCustomView(View view, ICustomViewCallback callback)
{
base.OnShowCustomView(view, callback);
FrameLayout frameLayout = view as FrameLayout;
_isVideoFullscreen = true;
_videoViewContainer = frameLayout;
_videoViewCallback = callback;
// Hide the non-video view, add the video view, and show it
_activityNonVideoView.Visibility = ViewStates.Invisible;
_activityVideoView.AddView(_videoViewContainer, new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent));
_activityVideoView.Visibility = ViewStates.Visible;
}
public override void OnHideCustomView()
{
base.OnHideCustomView();
if (_isVideoFullscreen)
{
// Hide the video view, remove it, and show the non-video view
_activityVideoView.Visibility = ViewStates.Invisible;
_activityVideoView.RemoveView(_videoViewContainer);
_activityNonVideoView.Visibility = ViewStates.Visible;
if (_videoViewCallback != null)
{
_videoViewCallback.OnCustomViewHidden();
}
_isVideoFullscreen = false;
_videoViewContainer = null;
_videoViewCallback = null;
}
}
}
Inflated .axml file (ported from original):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- View that will be hidden when video goes fullscreen -->
<RelativeLayout
android:id="@+id/nonVideoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- View where the video will be shown when video goes fullscreen -->
<RelativeLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"/> >
</RelativeLayout>
I am very new to Xamarin and Android development so I might be going about this all wrong. Please let me know if there are other ways of handling this much easier. I'm forced to use this setup with WebView and videos in iframe's but other things I'm not aware of might be possible to change. Any help is much appreciated.
Storyboard does not load anymore after upgrading Xcode to version 9.1 (9B55)
After the update of Xcode to build 9b55 this morning my storyboard did not load anymore.
Xcode is too new
'This file has been edited in a version of Xcode which is unsupported by the designer. Documents saved in Xcode 9.1 format, or older, are supported.'
I did not even open the storyboard in Xcode Designer... I use the alfa channel 7.3 Build 708 of Visual Studio.
Is there anything that I can change in the XML of the storyboard to make it open in Visual Studio again ?
The storyboard starts with :
<?xml version="1.0" encoding="UTF-8"?>
Would lowering the toolsVersion work ? If so, what would be a "good" version ?
Thanks
Bert