I just updated my XF to the latest pre-release and realized that extension to bind using expression (object.setbinding is obsolete now. Is there a replacement for this method available? I have a large application and I don't want to bind to strings. This extension made the code so refactoring friendly.
BindableObject Extension to apply binding from an expression is obsolete?
Master detailed page bug
I integrate azure push notifications in my project but it seems that there is a bug in xamarin with master detailed page when ever I click on the notification I got this error java.lang.IllegalStateException: Activity has been destroyed
when I change main page to content page error is gone. any help please
Mixing XAML and c#
Is there anyway to create pages with XAML and c# together ?
e.g. I want to code pages in XAML and have some parts dynamically generated from a datasource.
Is there a "model" example of a custom renderer, taking into account error handling, memory use etc?
I keep seeing custom renderers being developed that contain the same errors, such as throwing null reference exceptions when navigating away from the page containing the related control. I suspect that many of them also contain (or have the potential for) memory leaks.
Is there a model example of a custom renderer that includes:
(1) Use of SetNativeControl
(2) Wiring up event handlers, and unwiring them again
(3) Memory handling that ensures all memory is released when no longer required
(4) Appropriate (i.e. as many as required, no more, no less) checks on Element, Control, newElement, oldElement
I've looked at a load of samples this morning, but most of them are so trivial that they don't show how all of the above should really be done.
Many thanks
How to create button pressed effect?
Hello,
I need to create a button/image/whatever that changes image while pressed to create the button pressed effect. How can i get to the 'while pressed' state? Even if using custom renderers, i cant do it. Could some one give me some hints?
Thanks
Xamarin Bug: "java.lang.IllegalStateException: Unable to create layer for "
Hi,
I think there is a bug in Xamarin Forms:
- Environment:
- Device: Samsung galaxy S7.
- Adroid OS: 6.01
- Xamarin Studio: 6.1.3
- Xamarin Forms: 2.3.3.180
Sample Code:
<Grid x:Name ="CountProduct" IsVisible ="false" VerticalOptions ="End" HorizontalOptions="End" Margin ="0, 0, 20, 20" HeightRequest ="25" InputTransparent ="true"> <ContentView InputTransparent="true" HeightRequest ="25" BackgroundColor ="Black" Opacity ="0.4"> </ContentView> </Grid>
Description:
"java.lang.IllegalStateException: Unable to create layer for " error happened when IsVisible = "false". There are so many case similar that.
If inner controller is ContentView, message : Unable to create layer for Platform_DefaultRenderer
- if inner Controller is CustomController, CustomControllerRender implement VisualElementRenderer. Message : Unable to create layer for CustomControllerRender
My app so big and there are many code that dropped in this bug. If i try to fix all to avoid this bug, my app will become to be unmanaged.
Please help me!
PopToRootAsync is not supported globally on Android, please use a NavigationPage.
Hi,
Does anyone have any additional information regarding how I might work around the "PopToRootAsync is not supported globally on Android, please use a NavigationPage." error?
The same code works successfully on Windows Phone.
Thank you very much for your help.
Paul Diston
Gradient as background color
I want to set a gradient background to a Xamarin.Forms layout and view. How can i do that?
A tricky but not very appealing is using a WebView and settings the gradient background using CSS but i want to avoid this.
I already searched the forum but didn't found anything, sorry if i missed something.
Why is My Xamarin.Forms app's Master Page Appearing Over Android's Notification Bar?
Hi all I am a bit new to Xamarin.Forms.
I am trying to build a MasterDetailPage (MainPage), with a Content Page (SideNavMasterPage) set as the 'Master'.
The 'Detail' is a NavigationPage created in code with another Content Page (ResultsListPage) set as the root.
Here is a screenshot of the issue:
Here is the code snippet for the MasterDetailPage (MainPage.cs):
`using BestBuy.Pages.Xaml;
public class MainPage : MasterDetailPage
{
SideNavMasterPage SideNavMasterPage;
public MainPage()
{
SideNavMasterPage = new SideNavMasterPage()
{
Title = "Menu"
};
Master = SideNavMasterPage;
Detail = new NavigationPage(new ResultsListPage()
{
});
Detail.ToolbarItems.Add(new ToolbarItem()
{
Text = "Duck Buy",
});
}
}
Here is the xaml for the Master (SideNavMasterPage.xaml):
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage.Content >
<StackLayout Padding="20,15,0,0" >
<ListView x:Name="SideNavMenuListView" SeparatorVisibility="None" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding MenuTitle}" ></Label>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage.Content>
`
Here is the cs for the Master (SideNavMasterPage.cs):
` public partial class SideNavMasterPage : ContentPage
{
private List SideNavMenuItems;
public SideNavMasterPage()
{
InitializeComponent();
SideNavMenuItems = new List<SideNavMenuItem> ();
PopulateSideNavMenu();
// SideNavMenuItems.Add
}
public void PopulateSideNavMenu()
{
SideNavMenuItems.Add(new SideNavMenuItem()
{
MenuTitle = "Home"
});
SideNavMenuItems.Add(new SideNavMenuItem()
{
MenuTitle = "Departments"
});
SideNavMenuItems.Add(new SideNavMenuItem()
{
MenuTitle = "Today's Deals"
});
SideNavMenuItems.Add(new SideNavMenuItem()
{
MenuTitle = "Settings"
});
SideNavMenuListView.ItemsSource = SideNavMenuItems;
}
}`
Does anyone know why the Xamarin.Forms app's Master is Appearing Over Android's Notification Bar? Or have any hints as to how I can resolve this?
Your assistance would be appreciated.
Unable to debug iOS Webview HTML/JS/CSS using Safari on Mac
Hi,
For my Cordova Apps I can connect the iPad to my Mac and debug the Webview HTML/JS/CSS content using Safari. But when I deploy Xamarin Forms iOS App Safari does not show the running App on iPad, can you please tell what I need to do to make it show up for debugging ? I have tried debug/release & other deployments.
-Thanks
Mahesh
How to make master detail page below the toolbar
Hi guys,
I want to make my master detail page appears below the toolbar.
Exactly like this
Instead this
Bluetooth unable to found nearest devices in Xamarin forms
Dear Xamarin Lovers.
i am tried the Xamarin.BluetoothLE-master from git hub only showing paired devices but unable to Scan the surrounding bluetooth devices.
many samples are tried but unable scan the nearest bluetooth devices. total 2 weeks ago time waste for me. could you please resolve this one.
as soon as possible
Thanks in Advance
Recycler view notifyDataSetChange not working from custom adapter
I have a customer list. First time it renders with all customers, then I added a filter to list only new customers. Modified the source items with new customers. But it is not rendering in the view. Adapter constructor is called with new set of array. But it is not invoking the method public override int ItemCount. This page will get rendered on screen lock and unlock of device. Please help me here
public class RecyclerViewRenderer : ViewRenderer<RecyclerViewList, RecyclerView>
{
.........
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == RecyclerViewList.ItemsProperty.PropertyName)
{
var items = (Element as RecyclerViewList).Items;
if (items != null)
{
adapter = new RecyclerViewAdapter(items);
adapter.ItemClickEvent += OnItemClick;
adapter.PopUpClickEvent += OnPopUpClick;
recyclerViewCustomers.SetAdapter(adapter);
adapter.NotifyDataSetChanged();
// Task.Delay(500);
}
}
}
......
}
ListView viewCell entry keyboard - binding bug with Android 7 (API 24)
See the example xaml below. This worked fine on API 23, but this morning my phone offered an Android 7 upgrade and I installed it. Now the binding / keyboard is buggy.
Basically, after editing the ItemName, when I enter data into the ExpectedQty or ActualQty entries the ItemName entry receives all the data being entered from the other entry controls. And i've noticed that the Numeric keyboard flashes up then is replaced by the text/default keyboard. Its as though the keyboard linked to the ItemName is being displayed, and hence the data is being fed to the itemname.
I've tried a few things like re-ordering the columns, using different keyboards, and it seems that the first column/keyboard always gets precedence and a similar problem occurs. I've uninstalled the app before redeploying..... cleaned the solution, deleted obj/bin..... before rebuilding.
I've proved this is definitely new to API 24. I created an emulator with API 24 and the same problem occurred. I installed the app on a Android 6.0.1 device and the problem doesn't occur, which makes sense because I haven't touched the related code for a while.
I tried upgrading to the latest version of Xamarin forms (2.3.1.114) and it didn't help.
<ListView.ItemTemplate>
<Entry Placeholder=""
Text="{Binding ExpectedQty,Converter={StaticResource DecimalConverter}}"
Keyboard="Numeric"
WidthRequest="60"/>
<Entry Placeholder=""
Text="{Binding ActualQty,Converter={StaticResource DecimalConverter}}"
Keyboard="Numeric"
WidthRequest="90"/>
How to convert image from Plugin.Media to Base64?
Hello,
I have an issue with my need to upload an image to my web server.
I'm using Plugin.Media from James Montemagno. I use this code to let the user select an image.
var media = CrossMedia.Current;
var file = await media.PickPhotoAsync();
Then, I have to convert that "file" to base64 to upload it to my web server, but I don't know how to do that since in PCL there's no System.IO.File.
How can I do that? Do you have any hint?
Thanks!
Issues with HTTPClient returning null response with async
I've been trying to get a JSON response from a server through php. I can confirm that the uri correctly returns the JSON string I'm looking for so it's not an issue on that end. Also, this is only an issue with async request and a regular HTTP request call returns the correct JSON string.
Here is my async method:
public async Task<List> getUserInfoAsync(string username)
{
var client = new System.Net.Http.HttpClient();
client.BaseAddress = new Uri(address); // address is of form "http://www.something.com/"
var response = await client.GetAsync(phpScript + username); // phpScript is of form "php?username=" with 'username' being the requested username to grab from the database
var userJson = response.Content.ReadAsStringAsync().Result;
var rootObject = JsonConvert.DeserializeObject<userRoot>(userJson);
return rootObject.user;
}
So the 'response' variable ends up null which in turn causes userJson and rootObject.users to be null as well. I can't seem to figure out what is going wrong with the code. Any tips? Thanks!
After Adding Pushnotification Plugin to xamarin forms, android app is not deployed
After Adding Pushnotification Plugin to xamarin forms, android app is not deployed. but Build is success.
How can I take some action when an image button is pressed for 5 seconds (or more) in Xamarin Forms?
I would like to take some action when an image button is pressed during a long time period.
I have tried some ways using Custom Renderes but have no success.
Does anyone have something like that working?
Thanks is advance,
Carlos
xamlParseException at position 7:3
i understand that the error is on line 7 the (:3) confuses me cause my research says that means the position in the line but
<Controls:HorizontalList x:Name="Work" ListOrientation="Horizontal" ItemsSource="{Binding}">
if position 3 is where the error starts from the code above..... that means Cont <-- error starts and i cant understand why
the entire error states that
Position 7:3 Type Controls:HorizontalList not found in xmlns clr-namespace:HorizontalListView;assembly=HorizontalListView
which is a different solution and assembly to the project running and it does contain the correct HorizontalList.cs in it so right now im just confused
ObservableCollection
How to delete / remove all elements from an "ObservableCollection"?
I have a "ObservableCollection" with items but I need clean because load new data different.