Hello
I would like to know how can we show Code in formatted way like we do in web pages and how to create a text area for editing code in Xamarin Forms, I am new to xamarin and xamarin forms
Thanks
How to edit and show code in Xamarin Forms
SnackBar Issue
Hi , in my Xamarin forms app, when the user clicks on delete icon , I am showing a snackbar with the provision of undoing the deleted item. Now if I make the app go in sleep(background), change the language of device through settings , open the app and now when I click on delete button snackbar is not displayed.
Same is working fine for IOS and Xamarin android.
Any help is appreciated. TIA
how to disable the space occupied by the activity indicator in xamarin forms Mobile application?
how to disable the space occupied by the activity indicator in xamarin forms Mobile application?
Consuming REST services
What is the best method for consuming REST services which are locally deployed? I am specifically having issues with utilizing HTTPS for iOS. When calling the web service from iOS (the iPhoneSimlator), I receive a "TrustFailure" web exception. I think this is because the certificate used is self-signed (it's not secure because I am using my internal IP address and the certificate is issued for localhost) when using IIS Express. Does this mean I need to "publish" my API to IIS (or Azure) and use a valid certificate in order to consume the service? This seems like a lot of work for development, especially since I am creating the REST service and mobile application at the same time.
My development environment is:
I have reviewed this and this, but neither really touch on this issue. Any advice on a streamlined workflow would be much appreciated.
How to load records at the bottom of ListView/RepeatableStack dynamically when scrolls down?
I am working on Xamarin mobile app development. I am using RepeatableStack to display collection records on a CarouselPage. This is working fine, when i have less number of records.
But when i have huge number of records, the page gets stuck on load and takes few seconds. This gives bad user experience.
I would like load more records on the fly, when the user scrolls the list down to the bottom. I would like to load it, only when user scrolls down to the bottom. So that, the RepeatableStack will have less number of records when the page loads. Has any one resolved this scenario in Xamarin(C#)?
Xamarin.forms: Unable to connect to locally hosted web service.
Hi guys,
I've been trying to connect with web service deployed in my local (which is running in tomcat). And I'm deploying my project in Android device. As you can see in the code below that I've used my local PC's IP address. Also in Android Manifest file, I turned on the "INTERNET" permission. If I run this url directly in browser, I get expected result. Please note that I had to remove "http" from the code in order to post it here.
` public async Task<List> getHospitalsByCityAsync(string city)
{
List hospitals = null;
string RestUrl = "192.168.15.100:8080/unsaarAPI/bismillah/city/" + city;
var uri = new Uri(RestUrl);
try
{
var response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
NswHospitalSearch nswHs = JsonConvert.DeserializeObject<NswHospitalSearch>(content);
hospitals = nswHs.hospitals;
}
}
catch (HttpRequestException e)
{
Debug.WriteLine(e.InnerException.Message);
}
catch (Exception ex)
{
Debug.WriteLine(@" ERROR {0}", ex.Message);
}
return hospitals;
}`
During debug, its doesn't reach at line if (response.IsSuccessStatusCode)
and after a while I get
Error: ConnectFailure (Connection timed out)
I've no clue how to fix this. I've been surfing online many hours; but can't find a suitable solution.
Can any one help. I would really appreciate it.
Thanks.
Expandable ListView
i am new in xamarin forms and i need to make expendable list view by Populating data from web services
Thank you
How to create Background Service in xamarin forms ??
How to create background service in xamarin forms !! I create a task to meet my friend today at 10 am and close the app, remind before 10 minutes to the meeting time phone is ringing or vibrate.
XF vs PWA
Threading problem: how to await?
We have a SDK shipped in two native libraries, let's say lib.framework
for iOS and lib.aar
for Android.
We needed to create a version for Xamarin, so we created a binding library for each of them (lib_ios_binding.dll
and lib_android_binding.dll
).
On top of this we created another abstraction level to enable the use of our SDK from Xamarin.Forms projects, a PCL made up of lib.dll
, lib.ios.dll
and lib.android.dll
. This level provides a set of interfaces (lib.dll
) which are implemented in both native libraries (lib.ios.dll
and lib.android.dll
) and the instances are resolved at runtime by the Dependency Service.
Our approach for consuming the server API in the native libraries is implemented by delegates/listeners. The delegate/listener of each operation is passed through the invoker method and called back once the response is received. We handle threads natively, by sending the operation to a background threads and returning immediately. Once the operation is completed (it could take a while) we call back the listener/delegate on the main (UI) thread.
Now we are requested to use the async / await approach by an integrator but we are not able to make it work properly.
As for now we have tried to use the TaskCompletionSource
in the PCL level, but we are losing context as we are not being called back all the times. The delegate/listener is not being invoked properly. We can assure the requests are being launched and they are reaching the server.
So we need a way to create something like a task to run the native request and be able to wait until the response is received and return the result.
Is this possible to achieve? What are we misunderstanding or doing wrong?
Any help would be highly appreciated.
Padding in Button
I've searched and found similar questions but no real answers. I have a Button. When the button appears in iOS there is no padding around the text. Look at the button labeled "Forgot Password".
When the button appears on Android there is padding around the text.
What is the correct way to deal with this?
Can someone give me advice for starting on a data table in xamarin forms?
I don't know what the best place to start for building a table in xamarin forms with rows and columns. Basically I'd want to implement something like a data grid/table with rows and columns and would have paging. Does anyone know the most efficient way to build such a thing? I currently have some hacky code that builds a grid in xamarin forms and just adds the children to the appropriate grid/column. I don't want to pay for something, I want to build it so I'd prefer to avoid telerik or devexpress . Thanks in advance
How to add and use the .Net Framework to a project?
greetings I am new in visual studio and with Xamarin.forms I am trying to make a multiplatform app, the app requires that I use a nuget package but that package is 100% compatible with the .Net standard 2.0 that I am using so when compiling it gives me a series of warning and errors, I want to change to the .Net Framework 4.6.1 that my VS recommends but when I try to change I can not since it does not give me the option to select another .Net Framework attached an image where I highlight the problem and with the warning messages that I find after compiling, it seems strange to me since I have installed the .Net Framework from 3.5 to 4.7.1 but it does not give me the option to use them. Please help me with this problem if you can tell me how to use the different versions of the .Net Framework, I thank them and please can explain it to me in an easy way since as I mention I am new and it is costing me a lot to understand these things I appreciate it a lot.!
How can I display the very recent image from gallery as a thumbnail of gallery?
Hello, I'm now developing my own camera application. Today, I want to know how can I display recent image from gallery as a thumbnail of gallery. This words may be diffiult to understand for you guys. So I prepare example.
As you can see in the picture, left bottom side, there is some thumbnail image of gallery, and that thumbnail is equal to the recent taken picture. How can I implement this with XF? Or, is there any way to do it through native? If so, please enlighten me both iOS and Android please. Thank you in advance.
Switching ContentViews Xamarin.Forms
I am trying to create a custom navigation Bar. I have set up my Navigation Bar and called it NavBar
, and added a ContentView above it containing the Current Displayed page. I have created a public variable containing the ContentView like so: public ContentView CurrentPage = new Featured();
and I have a StackLayout set up in the Page like so:
var stacklayout = new StackLayout { Spacing = 0 };
stacklayout.Children.Add(CurrentPage);
stacklayout.Children.Add(NavBar);
Content = stacklayout;
I have a function that is called when a button on my NavBar is pressed to change the value of CurrentPage, set up like this:
void NavToBuy(object sender, EventArgs e)
{
CurrentPage = new Buy();
}
But when the button is pressed, nothing happens. I think that the value is being changed, but not displayed on the screen. Is there any way to fix this? Thanks for any help in advance
UITest doesn't affect code coverage
We are working on a Xamarin.Forms project and trying to improve our code coverage. Until recently, we only wrote unit tests for our model, which leaves tons of view pages untested. We are trying to use UITest to test these pages, but it doesn't work. When I run "analysis code coverage" from VS2017, the view pages tested by UITest still get 0% covered. Anyone knows how to fix that or any idea about how to test the view page to improve the code coverage? Thanks!
Modern UWP Controls
Is there any plans to make some of the UWP controls more complete/modern? At the moment my main concern is the Table View, I might as well be in an RTM Windows 8 app, even forces the string to lower, its just plain ugly in a Windows 10 app! Also the Text and Entry cells have no padding at all, while the iOS and Android ones do, I can't add margins to ListViews/TableViews as it ruins the iOS and Android experience (going to look into custom cell renders).
A lot less important but worth noting, while this isn't actually either an incomplete or old control, is the command bar only allowing the text of icons beneath the icon instead of too the side, I feel this may be asking too much of Xamarin.Forms and should perhaps look at custom renderers again I have also thought of using this, adding a 'TextToSide' property and making the UWP renderer.
Just want to know if there is anything out there to help with the problem before I go making custom renderers.
xamarin forms map is not showing
like upper image xamarin map is not showing.
i already access android permission.
how can i solve this problem?
Using TabbedPage as a wizard
Hi guys,
I have a following implementation made with TabbedPage and preety much working with the services.
However in order to make it more user friendly and yet control the navigation in specific way, I have following requirements.
Req 1. User must navigate through step 1 to step 2 and so on .. *(Tabs must still be clickable and user only can move further, if he has filled that step completely, User can move through Tabs which are correctly filled in any fashion however should be restricted to the step which has error/empty fields).
I am trying to implement some behaviors here- am I on right track?
Req 2. All the tabs data (MVVM Properties) must be made available for review on final tab, i.e. step 1 to step 6 data in final tab.
(Since I am using Prism Library I tried this with Éventaggregator, however I am not able to get through.)
Can you guys please suggest a good solution?
Thanks.
N Baua
custom viewrenderer for UILabel overlaps text inside list view on scroll
I am using a couple of sources to make a custom renderer for a label that can display htmlstring and has data detectors. On android, it works perfectly, but ios implementation has some issues. Here's the ios implementation :
`using System.ComponentModel;
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(HyperLinkLabel), typeof(HyperLinkLabelRenderer))]
namespace YourNameSpace
{
public class HyperLinkLabelRenderer : ViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
var view = (HyperLinkLabel)Element;
if (view == null) return;
var attr = new NSAttributedStringDocumentAttributes();
var nsError = new NSError();
attr.DocumentType = NSDocumentType.HTML;
var myHtmlData = NSData.FromString(view.Text, NSStringEncoding.Unicode);
UITextView uilabelleftside = new UITextView(new CGRect(0, 0, view.Width, view.Height));
//uilabelleftside.Text = view.Text;
uilabelleftside.Editable = false;
uilabelleftside.AttributedText = new NSAttributedString(myHtmlData, attr, ref nsError);
uilabelleftside.Font = UIFont.SystemFontOfSize((float)view.FontSize);
// Setting the data detector types mask to capture all types of link-able data
uilabelleftside.DataDetectorTypes = UIDataDetectorType.All;
uilabelleftside.BackgroundColor = UIColor.Clear;
// overriding Xamarin Forms Label and replace with our native control
SetNativeControl(uilabelleftside);
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == Label.TextProperty.PropertyName)
{
var view = (HyperLinkLabel)Element;
if (view == null) return;
var attr = new NSAttributedStringDocumentAttributes();
var nsError = new NSError();
attr.DocumentType = NSDocumentType.HTML;
var myHtmlData = NSData.FromString(view.Text, NSStringEncoding.Unicode);
UITextView uilabelleftside = new UITextView(new CGRect(0, 0, view.Width, view.Height));
uilabelleftside.AttributedText = new NSAttributedString(myHtmlData, attr, ref nsError);
uilabelleftside.Font = UIFont.SystemFontOfSize((float)view.FontSize);
uilabelleftside.Editable = false;
// Setting the data detector types mask to capture all types of link-able data
uilabelleftside.DataDetectorTypes = UIDataDetectorType.All;
uilabelleftside.BackgroundColor = UIColor.Clear;
// overriding Xamarin Forms Label and replace with our native control
SetNativeControl(uilabelleftside);
}
}
}
}
`
When I scroll down or up and an item reappears, it fires OnElementChanged with different values and this causes the text of the renderer to overlap.
Here's my Xaml:
<TabbedPage.ItemTemplate> <DataTemplate> <ContentPage Title="{Binding title}"> <ListView ItemsSource="{Binding Posts}"> <ListView.RowHeight> <OnPlatform x:TypeArguments="x:Int32" iOS="200" Android="220"/> </ListView.RowHeight> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid Padding="8"> <Grid.ColumnDefinitions> <ColumnDefinition Width = "50"/> <ColumnDefinition Width = "*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height = "40"/> <RowDefinition Height = "3"/> <RowDefinition Height = "*"/> <RowDefinition Height = "30"/> </Grid.RowDefinitions> <Image Grid.Column = "0" Grid.Row = "0" Source = "{Binding author.avatar_url}" Aspect = "AspectFill" WidthRequest = "40" HeightRequest = "40" HorizontalOptions = "Center" VerticalOptions = "Center"/> <Grid Grid.Column = "1"> <Grid.ColumnDefinitions> <ColumnDefinition Width = "*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height = "15"/> <RowDefinition> <OnPlatform x:TypeArguments = "GridLength" iOS="10" Android="15" /> </RowDefinition> </Grid.RowDefinitions> <Label Grid.Row = "0" Style = "{StaticResource authorName}" Text="{Binding author.full_name}" /> <Label Grid.Row = "1" Style = "{StaticResource proffInfo}" Text="{Binding author.proffInfo}" /> </Grid> <Grid x:Name = "postContent" Grid.Row = "2" Grid.Column = "0" Grid.ColumnSpan = "2" > <Grid.RowDefinitions> <RowDefinition Height = "30"/> <RowDefinition Height = "*"/> </Grid.RowDefinitions> <Label Grid.Row = "0 " Style = "{StaticResource heading1}" Text = "{Binding title}" /> <!--<WebView Grid.Row = "1"> <WebView.Source> <HtmlWebViewSource Html="{Binding html_content}"/> </WebView.Source> </WebView>--> <renderers:HyperLinkLabel Grid.Row = "1" Text="{Binding html_content}" /> </Grid> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </ContentPage> </DataTemplate> </TabbedPage.ItemTemplate>
The xaml shouldn't be an issue cause it renders on android just fine.