I implemented a Entry effect which only needs to be applied on iOS. Right now, I'm attaching it in code-behind by making sure the current platform is iOS. Is it possible to do this easily in XAML instead (i.e. do not attach it on other platforms)?
Is it possible to attach an effect in XAML on only one device platform?
The name 'InitializeComponent' does not exist in the current context
This is really strange and inconsistent. Sometimes it runs fine and sometimes I get the following error
'The name 'InitializeComponent' does not exist in the current context'
There is absolutely no change in code and project settings. Just sometimes it runs and sometimes it throws this compilation error. How to resolve this?
How to get absolute path of a file stored in application?
Hello,
I am working on Xamarin.Forms application.
I have a folder named "ProjectsDoc" in my PCL project. There are two files in it - File1.pdf and File2.doc.
Now I need to get the path of these files and open them in the default app installed in user's phone when user click on specific button. I have checked over different posts/articles but could not find how to do so. Can you please help me how can I get the path of these files?
Thanks
Loading an Image from a Resource in xaml
I have a resource called biglogo.png
added via the Resource menu and now it's in the Resources folder of my project.
I want to use it via xaml but neither
nor
seem to work. Is there a straightforward way to make it work?
Binding Two Properties from a list in XAML
I have a list that I am getting from a Database with TimeStarted and TimeEnded. I would like to combine them both into a Timespan for a listView. How can I make a new property in my ViewModel that combines those two properties (or maybe do it directly in XAML with a value converter)?
How to add padding to SearchBar inside Horizontal StackLayout?
For some purpose I want to position SearchBar inside StackLayout whose Orientation is Horizontal and add padding to that StackLayout but I found that the SearchBar takes all the Width space as shown in second SearchBar while when the Orientation is Vertical it works normally as shown in first SearchBar the below image:
Here is the code for both StackLayouts:
<StackLayout Orientation="Vertical" Padding="100,0,100,0">
<SearchBar/>
</StackLayout>
<StackLayout Orientation="Horizontal" Padding="100,0,100,0">
<SearchBar/>
</StackLayout>
I also tried to put the Horizontal-Orientated StackLayout into a Vertcal-Orientated StackLayout as shown in code below:
<StackLayout Orientation="Vertical" Padding="100,0,100,0">
<StackLayout Orientation="Horizontal">
<SearchBar/>
</StackLayout>
</StackLayout>
But it does not help too, So how to solve that problem?
How keep recent Entry value when go next page.
Hi, i want to keep entry value which i type in entry box then i go another page and then went back to the main page where previously i type somethings in entry box. Now how i keep those data without save in local database.
Binding to an element of an array (or List)
After much googling, I haven't found an answer to this.
I have an array of colors. I want to bind a Button's BorderColor to a specific element within an array.
What is the syntax to achieve this?
Xaml:
BorderColor="{Binding ButtonColors[11], Converter={Services:ByteToBorderColourConverter}}"
ViewModel:
private List<byte> buttoncolors;
public List<Byte> ButtonColors
{
get => buttoncolors;
set
{
buttoncolors = value;
OnPropertyChanged();
}
}
...
ButtonColors[11] = (Byte)Data[3];
I've also tried implementing this with List, but it also doesn't work.
I think the xaml binding syntax is incorrect maybe?
Upgarding to xamarin forms nightly version causes null reference exception
We have created a custom control and used customrender for converting it forms to native. We faced null reference exception only when using the 3.5.0.979221-nightly version and it works fine when using 3.3.0.912540. On further analysis we found that the null reference exception occurs in all Xamarin forms nightly version. Can any one please explain the difference between the Xamarin forms nightly version and normal xamarin forms version. We don't know what the reason for this. Could anyone please help to resolve the issue. The sample code is given below
public static IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid)
{
IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty);
if (render == null)
{
render = Platform.CreateRenderer(source);
source.SetValue(RendererProperty, render);
var p = PlatformProperty.GetValue(valid);
PlatformProperty.SetValue(source, p);
IsPlatformEnabledProperty.SetValue(source, true);
}
return render;
}
I have also attached the image showing the issue.
Frame CornerRadius for each side
Hi,
Xamarin froms frame need to set custom radius. For Left side different number and right side different radius, Is it possible to do like this?
Thanks in advance.
Round Stacklayout OneSide(Left Top and Left Bottom)
Hello Delveloperd,
I want to implement only one side round stacklayout (Left Top and Left Bottom).
It's posible in xamarin forms and blow i upload a image for example like this.
any guid for this
Thanks
Deepak
Cross Platform Camera Frame Analysis
Is there a way I can access ios/Android camera frames to do real-time frame analysis?
Is there a Recipie to implemnt a custom NavigationPageRenderer for the UWP Platform
Hello,
I am trying to add a AppBar to a Xamarin Forms Application targeting the UWP platform. From what I understand UWP has a top an bottom app bar definde on the page and therefore I would like to access it. As it is not possible to do it directly I think I need a custom renderer for the NavigationPage - the same thing was also necessary for the project's iOS page.
When I tried to follow the reciepie that I have used in the iOS and Andoid application to modify the layout of the NavigationPage I found that this is not possible as most of the methods are private or not overridable in the UWP NaviationPageRenderer.
So is there a some guidance how to modify the NavigationPage of an UWP application or is this the wrong approach all together? I spent extensive time on the internet and so far have not found any solution.
A sample putting me in the right direction would be much appreciated.
TIA
How to update value in listview
Hi I am using 2 Entry filed in List view One In Item Price and other is Quantity. I want to update sub total when value changed in Item Price or Quantity.
I have add a image for reference.
How to open excel sheet in your app
i am using xamarin forms how can i open excel sheet in my app its urgent
Issue while opening Xamarin form from BroadcastReciever class
This is for tracking incoming and outgoing phone calls. I am pushing a Xamarin form in the application Navigation stack from BroadcastReciever class using following code:
var phoneAddPage = new SomePage();
Xamarin.Forms.Application.Current.MainPage = new NavigationPage(phoneAddPage);
The page is getting pushed properly as expected. Issue is the page is overlapped by Splash Screen when application is opened. The form is functioning properly, overlap is the only issue.
Use .Xaml X:names in another .Xaml.cs?
Hi, can anybody tell me if this is possible and the best way to do it.
I have created a ContentView which is called Page21.xaml inside that file I have an Entry with an x:Name of 'page21entry'. Is there anyway to pull that through to my MainPage.xaml.cs so I can use it in a function.
Hope that makes sense
Fix black screen after splashscreen in Android using Xamarin Forms
I have a little problem, the splashscreen is loaded fine but, after that appear a black screen until the app is loaded.
I was seaching for days but and I can't find a solution,
Is someone have a solution for this?
I follow this instructions to get a splashsreen centered:
MainActivity.cs
[Activity(Label = "AppName",
Icon = "@mipmap/icon",
Theme = "@style/MainTheme",
MainLauncher = false,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "https://waze.com/ul")
]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
static readonly string TAG = "X:" + typeof(MainActivity).Name;
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Rg.Plugins.Popup.Popup.Init(this, bundle);
Xamarin.FormsMaps.Init(this, bundle);
AndroidAppLinks.Init(this); //enlace profundo
LoadApplication(new App());
if (Intent != null && Intent.DataString != null)
{
try
{
string email = "";
email = Intent.Data.GetQueryParameter("email");
if (email != null && email != "")
{
Xamarin.Forms.MessagingCenter.Send<string, string>("", "AppLaunchedFromDeepLink", email);
}
}
catch (Exception e)
{
//Catch error
Log.Debug(TAG, "Ha ocurrido una excepcion en MainActivity: " +e);
return;
}
}
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
SplashActivity.cs
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(SplashActivity).Name;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
Log.Debug(TAG, "SplashActivity.OnCreate");
//StartActivity(typeof(MainActivity));
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() => { SimulateStartup(); });
startupWork.Start();
}
// Simulates background work that happens behind the splash screen
async void SimulateStartup()
{
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
await Task.Delay(1000); // Simulate a bit of startup work.
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
//Finish();
}
}
styles.axml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#901D3E</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#7c1231</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#901D3E</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#901D3E</item>
</style>
</resources>
splash_screen.axml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#901D3E</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#7c1231</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#901D3E</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#901D3E</item>
</style>
</resources>
I know that if I follow this video, I can get a successful splashscreen (using only a image like a splashscreen) without black screen, but when the orientation is change, the image is it distorts.
Thanks in advances.
Unable to build after upgrading to Xamarin.Forms 3.4 or 4.0 from 3.3
Hi Guys, hope you can help because this is driving me nuts.
After updating Xamarin Froms to either 3.4 or 4.0, I get a build error for every XAML file.
If I upgrade to 3.4 then the error is:
Valu cannot be null, parameter name method
If 4.0 then it varies between:
Type Color not found in xmlns xamarin. com/schemas/2014/forms
Type Binding not found in xmlns xamarin. com/schemas/2014/forms
Type StaticResource not found in xmlns xamarin. com/schemas/2014/forms
Type RowDefinition not found in xmlns xamarin .com/schemas/2014/forms
I have killed bin and obj directories, cleared nuget cache, turned everything on and off again.
Also tried in Visual Studio 2017 (15.9) & 2019 and the same happens