in my app I have a Web View that hosting a local HTML file and I want to do the following :
first, I want to pass a string data from c# to local HTML and display this data in a paragraph tag.
then I want to back to pass the same data that in the paragraph tag from HTML to function inside c# code
how can I do that ?
how to pass a string data from c# to webview and vice in xamarin.form
notify
Hi,
How send a message notify in forms?
Xamarin.Forms 2.1.0 - Force cell to resize to fit controls
In my app, a cell content will change when highlighted. A few controls will be visible instead of "gone". This should make the cell resize to show the new controls.
Previously, this worked just fine. After the 2.1.0 update, this behaviour is not there any more.
I'm already using custom renderers and I know when the cell should resize, I just need to have a method to tell a cell to resize / recalculate its size. How do I force a cell to recalculate its size?
It's really sad when the app breaks so much after an update.
Android bug 1.4.3.6358-pre2: OnCellPropertyChanged not called for the first visible cells
public class CellThreadNative : ViewCell
{
public DataObjectType DataObject { get { return BindingContext as DataObjectType; } }
protected override void OnBindingContextChanged ()
{
base.OnBindingContextChanged ();
// Forward event
DataObject.PropertyChanged += (sender, e) => {
OnPropertyChanged (e.PropertyName); // Put a breakpoint here, you can see that it clearly does fire the event
};
}
}
[assembly: ExportRenderer (typeof (CellThreadNative), typeof (CellThreadNativeRenderer))]
namespace XXX {
public class CellThreadNativeRenderer : ViewCellRenderer
{
// This is broken, doesn't always get triggered (e.g. on the first visible cells)
protected override void OnCellPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnCellPropertyChanged (sender, e); // Put a breakpoint here
}
}
}
To test it:
Change a property on the item when it is selected in the ListView, for example:
ItemSelected += (sender, e) => {
selected = SelectedItem as DataObjectType;
selected.SomePropertyThatFiresOnPropertyChanged = Random.Next();
}
You will see the event getting caught and OnPropertyChanged getting called in CellThreadNative. However, OnCellPropertyChanged will not be called.
Now, scroll down a little bit to reach a currently not visible cell, and select it. Everything will work fine.
Scroll a lot down then scroll all the way up to the cells that were not working. Select one of them, and now it works all fine.
The workaround for this bug is to implement your own delegate on the XamForms ViewCell then assign it a method on the renderer. Use that delegate instead of relying on OnCellPropertyChanged i.e. redo things manually
tl;dr: The first few cells that will be visible when the ListView is displayed do not trigger OnCellPropertyChanged when a PropertyChanged event is received.
Email doesn't work in Xamarin Forms
Im using MVVMCross, and Xamarin Forms - and I need to send email from my App (iOS).
I typically use the MvvmCross Email plugin - but this time it doesn't work.
I have also tried the Xam plugin for email (both from Component Store, and Nuget) and no email view controller ever appears.
I get no errors, just nothing happens - the exact same result with both the MvvmCross plugin, and Xam Plugin.
Does anyone know why this is? Is it a known issue?
Thanks
confused about XLabs.Forms.Controls.ExtendedEntry
Hi Folks,
I'm not sure why but after adding XLabs.Forms with NuGet to my PCL project and adding the xmlns like so:
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=choices"
x:Class="choices.Views.WordListView">
It can't find the ExtendedEntry in there when I run it (Android):
04-06 19:39:00.581 I/mono-stdout(26725): Position 81:18. Type controls:ExtendedEntry not found in xmlns clr-namespace:XLabs.Forms.Controls;assembly=choices at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00039] in <filename unknown>:0
And is the <filename unknown>:0
a bad sign?
If I double click on the reference, it's clearly in there, so I have no idea what I'm doing wrong. Any ideas?
Thanks a lot,
Mike
ListView drag and drop items
Hi friends
I have a simple ListView with a ViewCell.
I would like to drag and drop items so I can order them...
Is it possible this in XF?
Thanks
Xamarin.Forms Animation not reducing width correctly
I'm trying to do simple animation to get a panel out and then close it. But somehow I'm missing something causing the animation very jittery when it slide in and it is not working at all with slide out.
When sliding in it flicker a bit at start after that it is smooth. While Slide out is completely not working for me.
Here is xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CustomProgressBar.Portable.Pages.Page1">
<ContentPage.Content>
<Grid>
<StackLayout VerticalOptions="Center" HorizontalOptions="End" >
<Button Text="CALL IN" x:Name="callInBtn" />
<Button Text="CALL OUT" x:Name="callOutBtn" />
</StackLayout>
<Grid VerticalOptions="StartAndExpand" HorizontalOptions="Start" HeightRequest="500" WidthRequest="50"
BackgroundColor="White" x:Name="pnl"></Grid>
</Grid>
</ContentPage.Content>
</ContentPage>
And respective code behind file,
public Page1()
{
InitializeComponent();
callInBtn.Clicked += (object sender, EventArgs e) =>
{
pnl.Animate("expand",
percent =>
{
var change = 350 * percent;
pnl.WidthRequest = change;
}, 0, 2500, easing: Easing.Linear);
};
callOutBtn.Clicked += (s, e) =>
{
var width = pnl.WidthRequest;
pnl.Animate("contract",
percent =>
{
var change = width * percent;
pnl.WidthRequest = width - change;
}, 0, 2500, easing: Easing.Linear);
};
//// Alternate animate using ViewExtensions
//callInBtn.Clicked += (s, e) => pnl.LayoutTo(new Rectangle(0, 0, 350, 500), 2500, Easing.Linear);
//callOutBtn.Clicked += (s, e) => pnl.LayoutTo(new Rectangle(0, 0, 50, 500), 2500, Easing.Linear);
}
What am I missing here?
Question about Windows.UI.Xaml.Application.Current.Resources within custom Renderer
Can someone explain to be how "Windows.UI.Xaml.Application.Current.Resources" behaves within a custom renderer? From looking at it, it would appear that this would provide access to the Windows Native Global Application Resource Dictionary (normally defined within App.Xaml). However when I look at various examples (especially in the recently opened source version of XF) it would appear that this might actually be an "aggregate" of ALL resources that are known at a specific point in time (Global App, Current Page, Current Control). So my question is -- which is? And if it is the latter, however are the keys in the dictionary setup. For example, if I am creating a custom control and I have a DataTemplate for it, this data template is local and as such would NOT have a key name -- so what name is used with in the Resource Dictionary?
Auto-hide/show navigation bar on listview scroll?
Is there a way to do this easily on iOS and Android? Any existing 3rd-party controls out there? Something similar to this but for Xamarin: https://github.com/tristanhimmelman/HidingNavigationBar
speak with forms
Hi,
How to speak with forms? I just know how to do with forms speak. I need now how to speak and forms write or understand my what i said. How to do this? Thanks.
Xamarin Forms STILL recycling images in ListView in latest release
So there have been previous threads on this, but images are STILL being recycled in the latest release of Xamarin Forms.
So I use a single image on the left, that is downloaded from a URL. The listview is fast and works great EXCEPT for the fact that as list cells are recycled you can see the old image before the new one loads, causing flicker and unpleasant artifacts for the user.
What can I do to reduce or fix this?
A question about "ImageSource.FromUri" Method (Xamarin.Form)
Hi guys,
I met a problem when using the method ImageSource.FromUri.
It is like this :
var imageNo = final["entityimage_timestamp"].ToString().ToLower();
var aid = final["accountid"].ToString().ToLower();
string strforuri = "https://magnetism2016.crm6.dynamics.com/image/download.aspx?attribute=entityimage&entity=account&id="+ aid + "×tamp="+imageNo;
Uri uu = new Uri(strforuri);
Showimg.ImageSource = ImageSource.FromUri(uu);
The url is with parameters, I am not sure why I cannot get the imagesource.
Thank you!
A class variable is not getting initialized in Xamarin.Forms app in iOS
This is the code of my class. In iOS, the _ContactDetails is set to null where as in Windows Phone 8.1 / Mobile 10 it is properly set to App.defaultContactDetails.
namespace my_project
{
public class MyClass : INotifyProperty
{
string _ContactDetails;
public event PropertyChangedEventHandler PropertyChanged;
public string ContactName { private set; get; }
public MyClass (string contactName)
{
_ContactName = contactName;
_ContactDetails = App.defaultContactDetails;
}
public string ContactDetails
{
get { return _ContactDetails; }
set
{
SetProperty (ref _ContactDetails, value);
}
}
bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
bool rtn_value = false;
if (!Object.Equals (storage, value))
{
storage = value;
OnPropertyChanged (propertyName);
rtn_value = true;
}
return rtn_value;
}
... ... ...
}
}
Handling iOS ListView Scrolled event in custom renderer throws InvalidOperationException
Here's my basic custom renderer:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App21;
using App21.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CustomListView), typeof(CustomListViewRenderer))]
namespace App21.iOS
{
public class CustomListViewRenderer : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
Control.Scrolled += ControlOnScrolled;
}
}
private void ControlOnScrolled(object sender, EventArgs eventArgs)
{
;
}
}
}
This is the error I get:
Resolved pending breakpoint at 'CustomListViewRenderer.cs:27,1' to void App21.iOS.CustomListViewRenderer.ControlOnScrolled (object sender, System.EventArgs eventArgs) [0x00001].
Unhandled Exception:
System.InvalidOperationException: Event registration is overwriting existing delegate. Either just use events or your own delegate: Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource UIKit.UIScrollView+_UIScrollViewDelegate
I'm not handling any PCL events. Is this a bug or am I doing something wrong here?
Complex bindings (Good or Bad) (ListView, ContextActions, MenuItem, Command, and CommandParameter)
Playing around with Xamarin Forms. I ran into a need for a complex binding.
I needed to get the Context Action MenuItem on a TextCell to bind to a Command that is a Property of the ViewModel the Page uses for it’s BindingContext. I got it to work with x:Reference (see the XAML) below.
The List will never get that large (50 items or so). I can see this being an issue with large amounts of items in a list.
Performance is good on my IPhone 6.
Looking for suggestions to see if this is a good or bad habit to get into with Xamarin Forms.
Thanks
<local:AccountsPageXaml
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BudgetManager.Pages.Accounts"
x:Class="BudgetManager.Pages.Accounts.AccountsPage"
x:Name="AcctsPage"
Title="Accounts">
<ContentPage.ToolbarItems>
<ToolbarItem Name="Add" Command="{Binding AddCommand}"/>
</ContentPage.ToolbarItems>
<ListView
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
ItemsSource="{Binding Items}"
SelectedItem="{Binding Item}"
>
<ListView.ItemTemplate>
<DataTemplate>
<TextCell x:Name="AcctName" Text="{Binding Name}">
<TextCell.ContextActions>
<MenuItem Text="Delete"
IsDestructive="true"
BindingContext="{Binding Source={x:Reference AcctsPage}, Path=BindingContext}"
Command="{Binding DeleteCommand}"
CommandParameter="{Binding Source={x:Reference AcctName}, Path=BindingContext}"/>
</TextCell.ContextActions>
</TextCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</local:AccountsPageXaml>
Problem with LG L39C Android 4.1.2
Hello everyone, I have developed an app and I distributed a beta tester through Play Store.
On a LG L39C with Android 4.1.2 the application start and displays a white screen ( holo theme) with half the application icon.
This is my AndoridManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.xxx" android:versionCode="81" android:versionName="1.0.031">
<uses-sdk android:minSdkVersion="15" />
<application android:icon="@drawable/icon" android:label="xxx"></application>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
How can I figure out what's the problem ?
Thanks in advanced.
Xamarin is not able to build
Hi,
I have Xamarin 5.9.5 installed on my mac. I facing trouble in build through Xamarin which was previously working.
I am getting this error (see Attachment No 1).
Main.cs(67,56): error CS0117: com.badlogic.gdx.Application' does not contain a definition for
LOG_DEBUG'
The package "com.badlogic.gdx.Application" is defined in one of the dll (xp) (see Attachment 2).
Through assembly browser I can see 'LOG_DEBUG' is defined in the same dll but how come
Main class is not able to find it.
I have also attached the complete build logs.
Xamarin Form Entry PlaceholderColor Doesnot work
There is an error in xamarin form when using PlaceholderColor for Entry Control. I am getting an exception when setting a PlaceHolderColor for an Entry control. Below is the exception.
System.MissingMethodException: Method 'Entry.set_PlaceholderColor' not found.
Detect scroll in Listview
I need to implement a event to catch Listview scroll state, similar to the event ScrollStateChanged (native or Mono Droid) because I would like to know the current scroll position to inject more content to the list. ScrollStateChanged is not available in Forms. Any ideas?
Regards