Ignore, I left some stuff out accidentally, and someone is helping me now (how do I delete a thread? I don't see the option).
New stack not being added
Set Toolbaritem icon
Hi,
I'm trying to set the icon of a toolbar item.
I have a forms solution with a project for Android and one for iOS.
As the icon attribute expects a FileImageSource I'm not able to simply set it to an ImageSource.
The documentation is guessing to load it by simply setting
TollbarItem.Icon = "icon.png"
but this is definitely not working.
In Android I stored the icon in the drawable folder and it's working fine. The image is loaded. But the problem comes with the iOS version!
In iOS I usually use the XCassets catalog and I don't see why I shouldn't especially as it is the default way in iOS development to manage images.
The Xamarin documentation mentions to copy the image in to the root folder of the project, what doesn't feel like a justifiable solution for me, but even if I do that it's not working!
I also tried to set it like ToolbarItem.Icon = "Images.xcassets/icon.imageset/icon.png";
but this, too, isn't working.
I assume I start from the Resources folder to load the image from. I tried for a whole day now but nothing works.
That's my code for that part (as said, working in Android)
string icon = "Images.xcassets/icon.imageset/icon.png";
if(Device.OS == TargetPlatform.Android)
icon = "icon.png";
if (Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS)
RegistrationButton.Icon = icon;
So, how can one set the icon of a ToolbarItem in iOS?
Thanks.
Best regards
How to change the status Bar color in Xamarin Forms IOS ?
I want to move from Master Detail Page to Navigation Page Everything works fine.I've a button on Navigation Page when we pressed this button A PushModalAsync is called and the text color changes from white to black.
Now what I want to ask you is that from the PushModalAsync page how to change the status bar color ?
FreshMvvm FreshTinyIoC.TinyIoCResolutionException
Hi @MichaelRidland,
I've implemented a custom MasterDetail navigation service, to have a custom master/menu page. I inherited from FreshMasterDetailNavigationContainer.
I created the custom Menu via a xaml page with a list for the Menu entries. If a list item is tapped, I resolve the page via FreshPageModelResolver and set the resolved page wrapped by a FreshNavigationContainer to the Detail property of the MasterDetailContainer. The binding of the tapped command is done via FreshEssentials ListViewItemTappedAttached.Command. This works just fine.
But if I then want to push a new page via CoreMethods.PushPageModel("a string", false, true) I get a FreshTinyIoC.TinyIoCResolutionException.
FreshTinyIoC.TinyIoCResolutionException: Resolve failed: DetailPage - Reason: Resolve failed: Int32 ---> FreshTinyIoC.TinyIoCResolutionException: Resolve failed: Int32
at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x00074] in <2c9607ea566c42259e3dd2ee50f95a71>:0
at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x00000] in <2c9607ea566c42259e3dd2ee50f95a71>:0
at FreshTinyIoC.FreshTinyIoCContainer.ResolveInternal (FreshTinyIoC.FreshTinyIoCContainer+TypeRegistration registration, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x001eb] in <2c9607ea566c42259e3dd2ee50f95a71>:0
at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x000ce] in <2c9607ea566c42259e3dd2ee50f95a71>:0
Can anyone give a clue here?
Xamarin Forms and Estimote SDK?
Hi,
I'm planning to develop a simple/basic iOs and android app using the estimote iBeacon android and iOs SDKs:
https://components.xamarin.com/view/estimotesdk
https://components.xamarin.com/view/estimotesdkios
Would it be possible to use these two SDKs in a Xamarin.Forms project?
Or would it be better to make to two "normal" Xamarin projects, one for iOs and one for android?
thanks in advance,
rudgr
Pass Click/Tap Event Through Levels of RelativeLayout
I'm placing RelativeLayouts on top of each other in the same grid row. The RelativeLayouts are set to FillAndExpand on both the HorizontalOptions and VerticalOptions. I want to be able to place them on top, but allow click events to pass through to the RelativeLayouts below, if nothing on the current RelativeLayout uses the Click/Tap event. Currently, the empty space in the RelativeLayout grabs the click/tap event and does not let it pass through.
Is there any way to allow tell RelativeLayout to pass the commands through to the layout items below?
Thanks,
John
HTTP Library
Hi
I am building a Xamarin.Forms app to run on Android, iOS and Universal Windows Platform (Windows 10). My app consumes an ASP.net Web API and would probably connect to other APIs as well via HTTP in the future. I am looking for a library that I can use for the HTTP calls that would work on all three platforms. I was told RestSharp was a good option, but it does not look like it is compatible with Windows 10.
Do you know any good options?
Best regards
Terence
How to have xor (exclusive or) colors in a png file?
I use .png files with transparent backgrounds for many of the images within my app. Typically, the main bits of the image will be black, and the rest transparent. This is great, until used above something that has a dark background. Is there any way, either in the .png format itself, or in code handling Xamarin.Forms.Image objects, to specify that pixels within an image should be xor'ed with whatever is behind, so that if the background is white, the pixels in the image will be black, but if the background is black, the pixels in the image will be white?
An alternative is to draw outlines around everything within the png file, so having a white outline around the black pixels in the image file, and everything around that outline being transparent. However, that uses up space within the image, so I'd rather go with xor'ing if it's possible (and without getting too slow).
How to set Button text without changes (not in uppercase)?
Hello,
I have this xaml for button:
<Button Text="Click here!" Image="icon.png" ContentLayout="Top, 0"/>
But the text is displayed in uppercase and I want it without changes. Is it posible?
Tabbed Page Action Bar Rendering
The follow is a way to overwhelm the issues when setup the action bar of a tabbed page project.
But before showing the rendered let make a short intro for the guys who is using this for first time.
PART 1 - XAML
The XAML code of a tabbed page is the follow:
`<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage.Children>
<ContentPage x:Name="tabKeypad">
<StackLayout
......Some Code
</StackLayout>
</ContentPage>
<ContentPage x:Name="tabContacts">
<Grid>
......Some Code
</Grid>
</ContentPage>
<ContentPage x:Name="tabFavourites">
<Grid>
......Some Code
</Grid>
</ContentPage>
<ContentPage x:Name="tabCallHistory">
<Label Text="Coming Soon" />
</ContentPage>
</TabbedPage.Children>
`
A short description of the XAML tabbed page is the follow:
<TabbedPage>
<TabbedPage.Children>
<ContentPage x:Name="Tab1"/> <!-- Remmber always to use x:Name and not Name (As may use it in a WPF app) -->
<ContentPage x:Name="Tab2"/>
<ContentPage x:Name="Tab3"/>
</TabbedPage.Children>
</TabbedPage>
Merging multiple resource dictionaries
How do you merge multiple resource dictionaries in Xamarin? Unlike WPF's MergedDictionaries
, the corresponding MergeWith
property is of type Type
and thus only allows you to specify a single dictionary. Currently I'm getting around it by adding them as global resources...
<!-- Application resource dictionary -->
<ResourceDictionary>
<ResourceDictionary x:Key="dict1" MergedWith="themes:MainTheme" />
<ResourceDictionary x:Key="dict2" MergedWith="core:CoreResources" />
</ResourceDictionary>
...and then merging them at runtime:
public App(Module platformModule = null)
{
InitializeComponent();
this.Resources
.Select(x => x.Value)
.Where(x => x is ResourceDictionary)
.Cast<ResourceDictionary>()
.SelectMany(x => x)
.ToList()
.ForEach(x => this.Resources.Add(x.Key, x.Value));
This works, but I can see it becoming both very slow and unnecessarily memory-intensive as my application grows.
Am I missing something obvious?
Sleep app in the middle of a bucle.
Hi guys, I've got a problem. I've got an app with a loop, that gets and process values and it represents this values on a circular gauge.
I invoke "Device.StartTimer (TimeSpan.FromMilliseconds (10), () =>" to create the animation and I do not want to get the next value until the gauge has the value that matches with the actual value.
My problem is that:
I tried to use Task.Delay to wait for the next value, but if the difference between the current value and the previous value is a few big,
The loop starts again, with no time for the gauge to complete the current round.
Can anyone help me? Thank you very much!
PD: I'm using Xamarin Forms portable!
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!
Getting errors while creating a new Blank Xaml App (Xamarin.Forms Shared) project
I'm trying to create a new Blank Xaml App (Xamarin.Forms Shared) project, and getting the below 18 errors.
Is that normal?? Anything I can do to fix that?
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 1 Active
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 2 Active
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 3 Active
Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 4 Active
Error CS0246 The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 6 Active
Error CS0246 The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 10 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 12 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 19 Active
Error CS0115 'App.OnStart()': no suitable method found to override App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 19 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 24 Active
Error CS0115 'App.OnSleep()': no suitable method found to override App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 24 Active
Error CS0518 Predefined type 'System.Void' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 29 Active
Error CS0115 'App.OnResume()': no suitable method found to override App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 29 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 14 Active
Error CS0103 The name 'InitializeComponent' does not exist in the current context App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 14 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 16 Active
Error CS0118 'MainPage' is a type but is used like a variable App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 16 Active
Error CS0518 Predefined type 'System.Object' is not defined or imported App1.UWP d:\Data\Projects\Xamarine\another test\App1\App1\App1\App.xaml.cs 16 Active
How to access controls defined in a ListView DataTemplate?
Hi,
Lets say I have a ListView in 'MyView' as follows:
<ListView x:Name="myList" ItemSource="{Binding MyData}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding FieldLabel}"/>
<Entry x:Name="myEntry" Text="{Binding MyEntry}">
<b:Interaction.Behaviors>
<b:BehaviorCollection>
<b:EventToCommand EventName="Completed" CommandParameter="{Binding .}" Command="{Binding Path=BindingContext.EntryCompletedCommand, Source={x:Reference Name=MyView}}"/>
</b:BehaviorCollection>
</b:Interaction.Behaviors>
</Entry>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
MyData has x items in it, lets say 10.
How can I set focus to the next entry field to the next item from within the EntryCompletedCommand event? and when the last one is 'completed' then focusing the first entry in the listview?
I've searched for a while now and have not found a straight forward answer!
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>
Simulate press home button by code
Is there any approach to simulate press home button by code with cross platform?
Thanks in advance
Confused about image size
Hi
Im a little confused about what image sizes to use if im building a iOS and Android app.
Do i calculate imagesize based on all iOS screensizes, and all the most popular Android screensizes?
Any suggestions?
Best regards
Jakob
CachedImage FFImageLoading for Xamarin.Forms
https://github.com/molinch/FFImageLoading or https://github.com/daniel-luberda/FFImageLoading/ (new Forms features)
DEMO: https://github.com/daniel-luberda/FFImageLoading/tree/master/samples/ImageLoading.Forms.Sample
Caching support
The library automatically deduplicates similar requests: if 100 similar requests arrive at same time then one real loading will be performed while 99 others will wait. When the 1st real read is done then the 99 waiters will get the image.
Both a memory cache and a disk cache are present.
By default, on Android, images are loaded without transparency channel. This allows saving 50% of memory since 1 pixel uses 2 bytes instead of 4 bytes in RGBA (it can be changed).
WebP support
WebP is supported on both iOS and Android.
Downsampling
Downloaded images can be automatically downsampled to specified size (less memory usage). DownsampleHeight and DownsampleWidth properties
Retry
Downloads can be repeated if not succeeded: RetryCount and RetryDelay properties.
Placeholders support
LoadingPlaceholder
ErrorPlaceholder
After this pull it'll also support Transformations!
https://github.com/molinch/FFImageLoading/pull/47
Transformations support
It doesn't modify original source images. Example:
RoundedTransformation
CircleTransformation
- GrayscaleTransformation
... and some more features. Feel free to test it. Not all features are on nuget yet (older version).
Error inflating class android.support.v7.widget.Toolbar after updaring to v7.AppCompat Version 23.3
I am creating a Xamarin Forms Project and using android.support.v7.widget.Toolbar with FormsAppCompatActivity. The code I'm posting below was working with Xamarin.Android.Support.v7.AppCompat Version: 23.0.1.3
But after I upgraded to 23.3.0 this has started throwing Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.toolbar exception.
Here is my code for MainActivity
[Activity(Label = "AppMob.Client", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
FormsAppCompatActivity.ToolbarResource = Resource.Layout.toolbar;
FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.FormsMaps.Init(this,bundle);
GoogleAnalyticsHelper.GetGASInstance().Initialize_NativeGAS(Application.Context); //For GA initialization
LoadApplication(new App());
}
}
This is my code for Resource.Layout.toolbar
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />