Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 75885 articles
Browse latest View live

Manually load views in Prism

$
0
0

I have a requirement to create dashboard or widgets in a Prism app. Basically you get a list of widgets based on your security level, you may only have access to x number of modules and within them, these modules can have to level navigation options (implemented) or a widget to present on the dashboard which has it's own viewmodel.

There's no nice way of loading in XAML like you can in WPF and it will have it's parent binding context etc.

I've been looking at different approaches for this, I thought of loading the views into a bindable collection and presenting then via a custom tileview control we have.

I found this post which involves creating your own region manager

http://stackoverflow.com/questions/28652090/xamarin-forms-dynamically-load-content-in-a-page

I was wondering if anyone has attempted this and if they run into memory management issues, as the dashboard is a details page in a masterdetail app it loads in and out of memory so I'd imagine I'd have to handle cleaning up the binding context of the views when the page is destroyed and any behaviors to allow navigation from the widget into modules.

I'm wondering if anyone has attempted something similar in Prism or in Forms in general

I know there's the dynamic forms nuget library but it hasn't been touched in a while and the Forms team don't seem to recommend that approach from what I saw on a Forum post.

Thought I'd ask before I spend a few weeks on it only to find out I've been a bit overambitious with Forms.


Display pdf, image in xamarin forms

$
0
0

Hi,

i need to display the .pdf or .img file based on the user chosen. i have been using the dependency service and below is my code snippet. but i getting the exception as "ActivityNotFoundException: No Activity found to handle Intent".

public SaveAndReadDocuments(string filename)
{
string sourcePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "App-Folder");
string destPath = Android.OS.Environment.ExternalStorageDirectory.Path + "/MaterialsReg/";
Directory.CreateDirectory(destPath);
File.Copy(sourcePath + "/" + filename, destPath + "/" + filename, true);

            Java.IO.File file = new Java.IO.File(destPath);
            Intent intent = new Intent(Intent.ActionView);
            intent.SetDataAndType(Android.Net.Uri.FromFile(file), "application/pdf");
            Forms.Context.StartActivity(intent);

}

[PRISM] Navigation in Tabbed Page

$
0
0

In my MainTabbedPage I have this:
https://codepaste.net/gk8u6j

In UsersPage I have a ListView. Thus, when user click on an item, it opens a detail page.
However, when the detail page appears, the tabs (Main, Group and Users) still there in the layout.

I want the same navigation effect of Facebook Messenger App and WhatsApp.
When the detail page (their conversation page) open, it opens over the Tabbed Page.

I've tried without this:
https://codepaste.net/uxgu46

But navigation doesn't work properly. Actually, this way, detail page opens like a modal and not a navigation page.

Any idea?
Thank you.

Touch Events in Xamarin.Forms?

$
0
0

Am I crazy or is there no way to get at basic touch events (up/down/move) in Xamarin Forms?

It's trivial to add a custom renderer for a control and then access the touch events in the Android/iOS implementation. Problem is this results in a lot of repeated code if you have multiple types of controls that you need to get touch events for (plus the need for customer renderers that I wouldn't otherwise need).

I tried making a "touch service" that would take in a VisualElement and the platform implementation would wire up all the listeners on that element. The problem is I can't figure out how to get from a VisualElement to a native control so that I can subscribe to touch events. For instance, in my Android implementation I tried RendererFactory.GetRenderer(visualElement).ViewGroup.Touch += (s, e) { /* touch handler code */ }, but that never gets triggered.

iOS 7.X Supported Still?

$
0
0

I have been deploying to a small subset of users that have been clinging to their 7.1.2 devices. I haven't been able to simulate or test recently just due to device availability and also it seems xcode left iOS 7 in the dust in one of my recent upgrades. I just updated the app and seem to have broken 7.1.2 compatibility unfortunately, with no real good way to test it?

How are devs developing for iOS 10 and 7?

How to restore the navigation stack after page suspend / resume in Xamarin.Forms

$
0
0

Hey Guys,

I'm just getting used to Xamarin.Forms and cant seem to find a standard way of restoring the navigation stack after a suspend / restore (like when the device gets rotated).

Using either the v1.3.0 release or maybe even xamarin.forms.labs I can capture some restore/suspend events, but I dont understand how I'm meant to restore the navigation stack in my app?

For example, if I have my HomeView and HomeViewModel, which has a list view of items. Somebody clicks the list view item and it navigates to my ItemView and ItemViewModel. Then the user rotates the screen - how do I restore them to where they just were?

Can anyone point me in the right direction?

Thanks

Matt

Cannot set SystemUiVisibility in FormsAppCompatActivity

$
0
0

Starting API 23, android allows to change the Status bar icon/text tint to dark when the bar background is a lighter color.

Adding the following code in OnCreate() of MainActivity works in Xamarin 2.3.1.114 but not in 2.3.3.180 and above. I was wondering if someone has used this and can point me in the right direction!

if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
//Window.AddFlags(WindowManagerFlags.TranslucentStatus);
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LightStatusBar | (StatusBarVisibility)SystemUiFlags.LayoutFullscreen | (StatusBarVisibility)SystemUiFlags.LayoutStable;
}

Exactly similar question here.

How to reference other projects

$
0
0

I am trying to use this component: https://components.xamarin.com/view/signature-pad in my forms app but it doesn't support UWP.
Another user here came up with this https://github.com/pthomas99/SignaturePad which is forked from the source of the first component I mentioned, but as there is no nuget for this version I'm not sure how to use it in my project.
I can build the sample project from this repo and it works great on UWP but I can't figure out how to implement it in my project? Can anyone point me in the right direction? I've tried referencing the same .dll's as the sample project which hasn't worked, not sure If I need to actually add all the files from this repo to my project?


Bluetooth printer

$
0
0

It possible to connect ios to mobile phone via bluetooth and print receipt using printer? Any sample to refer?
please help me

thanks in advance

Proper ViewModel Structure

$
0
0

Since I've been hearing that each view should have its own view model, can I just make the code behind of each page its view model?

How to create a TabbedView

$
0
0

Hello everyone,
i want to create a TabbedView but i haven't yet idea to create it. Anyone can give me some idea, PLZ!!!
Thanks so much!!!

plz help me to solve the errors

$
0
0

these are my errors in styles.xml :

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
No resource found that matches the given name: attr 'colorAccent'.
No resource found that matches the given name: attr 'colorPrimary'.
No resource found that matches the given name: attr 'colorPrimaryDark'.
No resource found that matches the given name: attr 'windowActionBar'.
No resource found that matches the given name: attr 'windowActionModeOverlay'.
No resource found that matches the given name: attr 'windowNoTitle'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
No resource found that matches the given name: attr 'colorAccent'.

Object instance exception thrown when bound collection of carousel view is cleared.

$
0
0

I have a carousel view who's itemsource property is set in Xaml and the view itself is created and managed by MS Unity as a singleton. When clearing the bound collection from within the view model I get an object instance exception thrown. But on further inspection it's not the collection which is null, it's the clear method itself which is indicated as an "unknown member". The carousel page works fine on Android an Windows phone, but on iOS I receive this problem.

ColorStateList in Xamarin.Forms on C#

$
0
0

Greetings!

I am trying to create custom renderer for control (radiobutton) and need to change it's color scheme:

int[][] states = new int[][] {
    new int[] { android.R.attr.state_enabled}, // enabled
    new int[] {-android.R.attr.state_enabled}, // disabled
    new int[] {-android.R.attr.state_checked}, // unchecked
    new int[] { android.R.attr.state_pressed}  // pressed
};

int[] colors = new int[] {
    Color.BLACK,
    Color.RED,
    Color.GREEN,
    Color.BLUE
};

ColorStateList myList = new ColorStateList(states, colors);

The question is:
How can I address control states ( for ex. "android.R.attr.state_enabled" etc.) in C# ?

I am sure you know it!
Thanks in advance

Why am I can't? [assembly:Dependency(typeof( ??)]

$
0
0

I see several people use this code, but in my code I can not make it work

[assembly: Dependency(typeof(Droid.Path.Config))]

namespace Droid.Path
{
public class Config : IConfig
{

Error

Severity Code Description Project File Line
Error CS7036 There is no argument given that corresponds to the required formal parameter 'loadHintArgument' of 'DependencyAttribute.DependencyAttribute(string, LoadHint)' Droid.Path D:_DESENV\Droid\Path\Config.cs 10

Screenshoot with details and assemblies

You can help me solve this problem.
I'm using on Visual Studio 2015

THANKS


not yet resolved string was not recognized as a valid datetimev xamarin forms

$
0
0

Dear Xamarin lovers i am facing the problem to convert to datetime in xamarin forms and app crashed.
please resolve this issue.

string time="24-01-2017 07:41:27";
DateTime dt1 = DateTime.ParseExact(time, "dd-MM-yyyy hh:mm:ss:tt", CultureInfo.InvariantCulture);

System.FormatException: String was not recognized as a valid DateTime.

Thanks in Advance

RadioButton custom renderer and Click event

$
0
0

Greetings !_badPeople = _goodPeople

I have created CustomRadioButtons based on:

https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms.Droid/Controls/RadioButton/RadioButtonRenderer.cs
and
https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms/Controls/RadioButton/CustomRadioButton.cs

I styled it and it works.
But with a few issues. Please help to sort out:

  1. How to place text on the left side of radio button itself (currently I removed radio button's Texts & made separate labels on the left) ?
  2. How to change color of "halo" when pressing radio button (currently it is pink, despite the fact that radiobutton itself is blue) ?
  3. "Click" event. How can I make a handler for it or use existing one (currently just CheckedChanged available as defined in 2 classes provided above) ?
  4. The code example:

radiobutton.CheckedChanged += (sender, e) =>
{
string label = rad1.LabelId;
this.FindByName

How could I define method for ALL CustomRadioButtons, like ".CheckedChanged += (sender, e ... " ?

Looking forward for your reply
Thanks in advance!

Xamarin fan

Deploy to Android device with Visual Studio

$
0
0

Hi all,

I'm trying to migrate our Forms app from Xamarin Studio to Visual Studio Professional 2015.

Currently I want to run the app on an Android device, but all the time I build the app and press run all that happens is that
Visual Studio builds the app without errors but never deploys it to the device.

I can select Debug Any CPU the Droid project and also the device in the run menu but it's not deployed.

The console is saying Build 2 successful (iOS and Android I guess) 0 error and then
Provide 0 successful, 0 errors, 1 skipped (I expect deploying was skipped)
but why?

It always build without problems in Xamarin Studio.

Best regards

Issue with Hello, Xamarin.Forms quickstart guide. What is wrong with this code?

$
0
0

After following the Hello, Xamarin.Forms quickstart guide, I received some errors with this code from the PhoneDialer.cs in the UWP section:
`
async Task GetDefaultPhoneLineAsync()
{
var phoneCallStore = await PhoneCallManager.RequestStoreAsync();
var lineId = await phoneCallStore.GetDefaultLineAsync();

        return await PhoneLine.FromIdAsync(lineId);

}
`
Which gives me these 3 errors:
CS0246 - The type or namespace name 'PhoneLine' could not be found (are you missing a directive or an assembly reference?)
CS0103 - The name 'PhoneLine' does not exist in the current context
CS0103 - The name 'PhoneCallManager' does not exist in the current context

I have followed the guide completely, have restarted the project several times, checked dependencies, updated all existing packages & scoured the internet for a potential solution, which has as yet eluded me. Any help would be much appreciated. If any further information is required let me know.

Implement background service to download data

$
0
0

I am implementing the app in xamarin form and have download button in same to download the data
but I want to download data in background even when app is not running
How we implement the same in xamarin form in all platforms android/ios/windows phone

Viewing all 75885 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>