I want one to one or group chat in xamarin forms?
How can we create a chating App in xamarin forms by using signalr?
Xamarin.Forms.UWP crash in OnLaunched() Native Toolchain ON
When build-setting "Compile with .NET Native tool chain" is ON, I get the following exceptions in Xamarin.Forms.Forms.Init(e); in OnLaunched():
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Additional information: Cannot load assembly 'ClrCompression'. No metadata found for this assembly.
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Additional information: Cannot load assembly 'sqlite3'. No metadata found for this assembly.
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Additional information: Cannot load assembly 'ucrtbased'. No metadata found for this assembly.
I can just continue and the app seems to run fine, but when the app is installed from AppStore, it just crashes.
Any ideas?
Tom
OnBackButtonPressed not called
Hi!
I'm trying to override the default behavior of the back button on ios. I have:
protected override bool OnBackButtonPressed ()
{
Debug.WriteLine ("test");
return base.OnBackButtonPressed ();
}
But when I touch on the back button this is never called... So, my question is: is this only working for android? Because on the ios docs we have "Event that is raised when the back button is pressed."
http://iosapi.xamarin.com/index.aspx?link=M:Xamarin.Forms.MasterDetailPage.OnBackButtonPressed()
Thanks
Toolbar with content page
Hello developers,
I am using the component https://github.com/thrive-now/BottomNavigationBarXF
I can't implement a toolbar in one contentpage of my bottomnavigation, example:
<ContentPage.ToolbarItems>
<ToolbarItem Order="Secondary" Text="Cerrar sesión" Activated="CerrarSesion"></ToolbarItem>
</ContentPage.ToolbarItems>
Not showing toolbar...
any solution ?
Regards.
Make my app "shareable"
Hi there !!
I'm developing an app on Xamarin Forms (Android/iOS). My app needs to be shareable for some types of file (as documents and images). I mean that from File Manager I can select a file and then press the share button and select my app to "share" the file. How can I do that ? I was looking at Share Plugin but I'm not sure that it is what I'm looking for.
Thanks !
Adding a picker in XAML
I'd like to add a picker control that has the values 1,2,3,4,5.
I tried the following...
<Picker SelectedIndex="{Binding NewCriterion.Importance}" >
<Items>
<x:String>"1"</x:String>
<x:String>"2"</x:String>
</Items>
</Picker>
to no avail. The documentation is a bit sparse on how to do this in XAML. Help?
Problem with prism modules and dependency injection on iOS if using "Link All" - can anybody help?
Hello,
I am using the modules of prism.
On Android, Win8.1, WinPhone8.1 and UWP the app works fine.
On iPhone Simulator too.
If I want to start the app on a real iPhone (Device) I must change the "Linker Options" of the ios-project to "Link all assemblies". Next step was to preserve some dlls from linking:
--linkskip=Microsoft.Practices.Unity --linkskip=Prism --linkskip=Prism.Unity.Forms --linkskip=Prism.Forms --linkskip=Microsoft.Practices.ServiceLocation
Now the application throws this error:
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Dvb.MobileCatalog.Module.KatalogPages.KatalogPagesModul", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type KatalogPagesModul does not have an accessible constructor.
At the time of the exception, the container was:
Resolving Dvb.MobileCatalog.Module.KatalogPages.KatalogPagesModul,(none)
I think, the app can not resolve the dependecy-injection I use in KatalogPagesModul (as shown in the examples from prism):
public class KatalogPagesModul : IModule
{
private readonly IUnityContainer _unityContainer;
public KatalogPagesModul(IUnityContainer unityContainer)
{
this._unityContainer = unityContainer;
}
public void Initialize()
{
_unityContainer.RegisterTypeForNavigation<HomePage>(PageNames.HomePage);
_unityContainer.RegisterTypeForNavigation<KatalogPage>(PageNames.KatalogPage);
_unityContainer.RegisterTypeForNavigation<ArtikelListePage>(PageNames.ArtikelListePage);
}
}
Can anybody help me to solve the problem?
How can I use RecycleElement with Custom Renderers in a ListView?
I have followed this guide to make a custom cell and a custom renderer. The custom cell displays properly, and everything works as expected until I try to add in
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Arguments>
Then I get a System.InvalidCastException: Specified cast is not valid
. Stack trace as follows:
> 0x24 in Xamarin.Forms.Platform.Android.ListViewAdapter.HandleItemClick at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:372,5 C#
0x34 in Xamarin.Forms.Platform.Android.CellAdapter.OnItemClick at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\CellAdapter.cs:142,5 C#
0x20 in Android.Widget.AdapterView.IOnItemClickListenerInvoker.n_OnItemClick_Landroid_widget_AdapterView_Landroid_view_View_IJ at /Users/builder/data/lanes/3819/5a02b032/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.AdapterView.cs:215,5 C#
I have tried to search around but I have not found any real answers. Since I followed the guide and the sample code, I really don't understand the problem. All of my data is bound, so I thought everything would just work automatically. When I use a non-custom cell and renderer, I can recycle just fine. I will post the other relevant files:
HandbookViewCell.cs (this is my custom cell, in the Forms PCL)
using Xamarin.Forms;
namespace MyApp.Pages.Routines.CustomCells
{
public class HandbookViewCell : ViewCell
{
public static readonly BindableProperty TitleProperty =
BindableProperty.Create("Title", typeof(string), typeof(HandbookViewCell), "");
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
}
}
HandbooksPage.xaml (the page with the custom cell)
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Pages.Routines.HandbooksPage"
xmlns:statics="clr-namespace:MyApp.Statics;assembly=MyApp"
xmlns:cells="clr-namespace:MyApp.Pages.Routines.CustomCells;assembly=MyApp"
Icon="hamburger.png">
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
Orientation="Vertical"
Spacing="0">
<ListView ItemsSource="{Binding HandbookInfo}"
x:Name="HandbooksView"
ItemSelected="HandbookClicked">
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Arguments>
<ListView.ItemTemplate>
<DataTemplate>
<cells:HandbookViewCell Title="{Binding DocumentTitle}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
HandbooksPage.xaml.cs
using MyApp.ViewModels;
using System;
using Xamarin.Forms;
namespace MyApp.Pages.Routines
{
public partial class HandbooksPage : ContentPage
{
private HandbooksViewModel _viewModel;
private bool _fromCompany;
private string _projCompName;
public HandbooksPage(Guid? projectId, string name, bool fromCompany)
{
InitializeComponent();
_projCompName = name;
Title = _projCompName;
_fromCompany = fromCompany;
_viewModel = new HandbooksViewModel(projectId);
_viewModel.RetrieveHandbookRoutinesList();
BindingContext = _viewModel;
}
async void HandbookClicked(object sender, SelectedItemChangedEventArgs e)
{
//since this is also called when an item is deselected, return if set to null
if (e.SelectedItem == null)
return;
var selectedHandbook = (HandbookInfo)e.SelectedItem;
var docId = selectedHandbook.DocumentId;
var topLevelRoutinesPage = new TopLevelRoutinesPage(docId, _fromCompany, _projCompName);
await Navigation.PushAsync(topLevelRoutinesPage);
//take away selected background
((ListView)sender).SelectedItem = null;
}
}
}
HandbookAndroidCellRenderer.cs (the renderer in the android project)
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Support.V7.Widget;
using Android.Views;
using Android.Widget;
using MyApp.Droid.Renderers;
using MyApp.Pages.Routines.CustomCells;
using MyApp.Statics;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(HandbookViewCell), typeof(HandbookAndroidCellRenderer))]
namespace HolteApp.Droid.Renderers
{
class HandbookAndroidCellRenderer : ViewCellRenderer
{
protected override Android.Views.View GetCellCore(Xamarin.Forms.Cell item, Android.Views.View convertView, ViewGroup parent, Context context)
{
var x = (HandbookViewCell)item;
var view = convertView;
if (view == null)
{
// no view to re-use, create new
view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.handbook_cell, null);
}
var drawable = AppCompatDrawableManager.Get().GetDrawable(context, Resource.Drawable.circle_drawable);
Android.Graphics.Color color = Palette.Secondary.ToAndroid();
drawable.SetColorFilter(color, PorterDuff.Mode.SrcAtop);
view.FindViewById<FrameLayout>(Resource.Id.hb_icon_frame).Background = drawable;
view.FindViewById<TextView>(Resource.Id.hb_text).Text = x.Title;
return view;
}
}
}
And the xml of the actually cell isn't important. Is there any reason why this exception should occur?
I did attempt to use the answer here but I still had the same problem.
Why is the text in a listview shown in accent color (android)?
When I use a listview in xamarin forms and compile fro android, the text is rendered in pink:
I believe that is the accent color.
I find that strange, why is this color used?
Xamarin.Forms Android app Relaunch not resumes
I have SlpashActivity which Launchs MainActivity and then MainActivity Starts Application.
1) SplashScreenActivity Code.
public class SplashScreenActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(new Intent(this, typeof(MainActivity)));
this.Finish();
}
}
2) MainActivity Code.
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
}
when app creates, I am going to android device home menu and when I press again application icon i relaunchs not resuming.
Effect doesn't work with binding
Because we have our own fonts and accessibility sizing I made effects to render label text, this works for hard coded text but not for text injected via binding. Anybody knows why and how to resolve it?
Works
<Label Style="{StaticResource BodyTextStyle}" Text="Title">
<Label.Effects>
<local:BodyStyleFontEffect />
</Label.Effects>
</Label>
Doesn't
<Label Style="{StaticResource BodyTextStyle}" Text="{Binding Title}">
<Label.Effects>
<local:BodyStyleFontEffect />
</Label.Effects>
</Label>
Problem starting WinPhone emulator [Hyper V problem]
Hello!
I have a problem starting the Windows Phone emulator. I've checked the BIOS Setup for the HyperV settings and the Windows Feature HyperV option, and both are marked. When I try to start the emulator, it throws me a message saying that the "Windows Phone Emulator can't start because the hyperV isn't running". I've followed some solutions but none worked for me.
http://stackoverflow.com/questions/26070567/unable-to-start-the-windows-phone-emulator
https://msdn.microsoft.com/library/windows/apps/jj863509(v=vs.105).aspx
Thanks!
Cross Platform Crop Image View
Hey,
Anyone have ever implemented some custom crop image UI that can be used in forms ios/android/win phone?
What I`m trying to achieve is something like instagram that crop a image to a square, so I can store in a db and show it in a circle image after to give my app a better design.
Someone have anything like this? So I will not start from scratch...
Thanks
Size Doesn't get applied to custom controls
I have a custom rendered view in android which is bound to some data in runtime, the problem is that when I use it without bounding the size gets calculated correctly, but when I create and bound the control in runtime after the form is initialized (with relative layout constraints) it always defaults to minimum size unless I set the exact size in pixels which I don't want to do, have anyone encountered such a problem before?
How do I define a StaticResource of type Thickness?
I am trying to define a StaticResource in an application-level ResourceDictionary, and I am having trouble with the following markup:
<Thickness x:Key="RelativeLayoutPadding">
<Setter Property="Top" Value="15" />
<Setter Property="Bottom" Value="15" />
<Setter Property="Left" Value="15" />
<Setter Property="Right" Value="15" />
</Thickness>
I know the ResourceDictionary works, because it works with other types that I am setting, such as Doubles. However, for this markup, I get the error message that the property "Top" cannot be resolved (with a XamlParse exception). I originally thought this might be because the Thickness structure may not have public static properties for its Top, Bottom, Left, and Right Doubles. However, I have seen sample code for LayoutOptions having its Alignment property defined as a StaticResource and it is unclear from the documentation as to whether or not either the Alignment property or the Top, Bottom, Left, and Right properties are static. All, however, are clearly public, so I don't understand why the Setter class should have any issue in setting these properties. Please provide assistance.
Thanks,
Jordan
Custom renderer for ListView not working/firing
Hi,
I need to implement transparent background on ListView's selected items. For now I'm working with Android only. By following many threads and guides in these forums, I have written a custom renderer for the ListView but it does not work. It seems it's still using Forms ListView instead of the custom renderer, as I have no effect and still get the colored background.
The code for the renderer looks like this:
`[assembly: ExportRenderer(typeof(NoSelectListView), typeof(NoSelectListViewRenderer))]
namespace SelectorResearch.Droid
{
public class NoSelectListViewRenderer : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
{
base.OnElementChanged(e);
Control.SetSelector(Resource.Drawable.noSelector);
Control.CacheColorHint = Android.Graphics.Color.Transparent;
Control.ScrollingCacheEnabled = false;
Control.Divider = null;
}
}
}`
The "noSelector" resource is inside an .xml file under Resources\Drawable. I get the same result if I use the built-in Android color. With a simple matching class:
`namespace SelectorResearch
{
public class NoSelectListView : ListView
{
public NoSelectListView(ListViewCachingStrategy strategy) : base(strategy)
{
}
public NoSelectListView()
{
}
}
}`
It did not work as it is, so I also tried to add the following custom renderer for the ViewCell:
`[assembly: ExportRenderer(typeof(NoSelectViewCell), typeof(NoSelectViewCellRenderer))]
namespace SelectorResearch.Droid
{
public class NoSelectViewCellRenderer: ViewCellRenderer
{
protected override Android.Views.View GetCellCore(Cell item,
Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
{
var cell = base.GetCellCore(item, convertView, parent, context);
var listView = parent as Android.Widget.ListView;
if (listView != null)
{
listView.SetSelector(Android.Resource.Color.Transparent);
listView.CacheColorHint = Android.Graphics.Color.Transparent;
}
return cell;
}
}
}`
This is my XAML (notice this is a prototype and I'll need a ViewCell later for more complex UI data templates):
<local:NoSelectListView ItemsSource="{Binding Numbers}" Grid.Column="1" ItemSelected="LV_ItemSelected"
x:Name="Lv1" SeparatorVisibility="None">
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Arguments>
<local:NoSelectListView.ItemTemplate>
<DataTemplate>
<local:NoSelectViewCell>
<local:NoSelectViewCell.View>
<Label Text="{Binding}" HorizontalTextAlignment="Start" FontSize="Large"/>
</local:NoSelectViewCell.View>
</local:NoSelectViewCell>
</DataTemplate>
</local:NoSelectListView.ItemTemplate>
</local:NoSelectListView>
Where the "local" namespace simply points to the root namespace and assembly (I get no compile or parsing errors).
The result I'm getting is exactly the same as I would with the built-in Xamarin.Forms ListView. What I do in the ItemSelected event handler is simply programmatically scrolling to a given element in the list.
Any help on finding what's wrong with my code would be appreciated. Thanks in advance.
Xamarin.Forms equivalent to fill_parent/match_parent and wrap_content?
This drives me nuts. I cannot make the Views to behave as I want to.
Carousel page - observable collection MVVM
I have few pages nested in carousel page. First page allows to add new element to observable collection, another one is a list view with binding to this observable collection. How should I handle such sharing observable collection? Every page have its own ViewModel.
Accessing Each Cell Selected Value in DataGrid
Hi,
I have created data grid for displaying set of information. It has List of data and each list item divided in to different cell. In my scenario i need to access each cell data for storing in to json file. Here i have attached image for the reference.~~~~
In this image selected cell has cross and green background. In my case i can able to select entire row . But i want to trigger the event based on each cell selection.
Also my code snap
**event **
_listView.ItemSelected += (s, e) =>
{
if (SelectionEnabled)
SelectedItem = _listView.SelectedItem;
else
_listView.SelectedItem = null;
ItemSelected?.Invoke(this, e);
};
**view model**
public Team SelectedTeam
{
get { return selectedItem; }
set
{
selectedItem = value;
System.Diagnostics.Debug.WriteLine("Team Selected : " + value.Name);
}
}
**properties**
public event EventHandler<SelectedItemChangedEventArgs> ItemSelected;
public object SelectedItem
{
get { return GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public static readonly BindableProperty SelectedItemProperty =
BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(DataGrid), null, BindingMode.TwoWay,
propertyChanged: (b, o, n) =>
{
if ((b as DataGrid)._listView.SelectedItem != n)
(b as DataGrid)._listView.SelectedItem = n;
}
);
Please help me to solve this issue
Thanks ,
Krupa
ListView dynamic cell height, Grid in cell not measuring correctly
I'm trying to get dynamically sized row heights working on iOS but running into some problems. So far I've tried making a custom listview datasource as well as a subclass of ViewCell that gets the size request of it's view when obtaining the view so that I can set the cell height.
The ViewCell subclass seems to be working better than the custom datasource, except that grids don't seem to be measuring correctly and I'm getting shorter rows than I should be.
I know this has been asked a bunch before but everything I find seems to end with someone from Xamarin saying it's been fixed and other customers saying that it's still broken.
As I spent the next however long trying to figure out how to make it work I figure it would be a good idea to ask - what are people using to dynamically size their rows? I'd very much prefer not to have to write custom layout logic.