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

ZXing.Net.Mobile (Xamarin.Forms/Android) Scan on different pages do not reaktivate scanner

$
0
0

I have implemented a Xamarin.Forms App focused on Android which should scan barcodes on different pages. (Followed this description ‚https://blog.xamarin.com/barcode-scanning-made-easy-with-zxing-net-for-xamarin-forms/‘ (Thanks! James Montemagno))

I initialize the scanner control (defined in xaml) in the constructor of the codebehind class:

    <ContentPage.Content>
        <AbsoluteLayout>
            <AbsoluteLayout.Children>
                <z:ZXingScannerView
                    x:Name="zScanner"
                    AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"
                    AbsoluteLayout.LayoutFlags="All"
                    HorizontalOptions="FillAndExpand"
                    IsScanning="True"
                    OnScanResult="ZScanner_OnOnScanResult"
                    VerticalOptions="FillAndExpand" />
                <z:ZXingDefaultOverlay
                    x:Name="zOverlay"
                    ShowFlashButton="False"
                    AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"
                    AbsoluteLayout.LayoutFlags="All"
                    HorizontalOptions="FillAndExpand"
                    VerticalOptions="FillAndExpand" />
….

For embedding into the own page layout I use the ZXingScannerView-Control.

    public TicketScan()
     {
         InitializeComponent();

         // https://components.xamarin.com/gettingstarted/zxing.net.mobile.forms
         // https://blog.xamarin.com/barcode-scanning-made-easy-with-zxing-net-for-xamarin-forms/
         var zXingOptions = new MobileBarcodeScanningOptions()
         {
             DelayBetweenContinuousScans = 1000, // msec
             UseFrontCameraIfAvailable = false,
             PossibleFormats = new List<BarcodeFormat>(new[]
             {
                 BarcodeFormat.EAN_8,
                 BarcodeFormat.EAN_13,
                 BarcodeFormat.CODE_128,
                 BarcodeFormat.QR_CODE
             }),
             TryHarder = true //Gets or sets a flag which cause a deeper look into the bitmap.
         };
         zScanner.Options = zXingOptions;

         // https://github.com/Redth/ZXing.Net.Mobile/issues/427
         zOverlay.BindingContext = zOverlay;

         fab.Clicked = OnClick_AddFabButton;
    }

The first scan page works as expected.
When I leave the page I pause the scanner here:

    protected override void OnDisappearing()
    {
        base.OnDisappearing();
        zScanner.IsScanning = false;
    }

(Otherwise the scanner will scan on each further page even if no scanner control is on the page (?!) And the camera works all the time.)
On a second page I try to initialize the scanner on the same way and set IsScanning = true.

        protected override void OnAppearing()
        {
            zScanner.IsScanning = true;
            base.OnAppearing();
        }

But on this second page I see only a frozen camera picture (maybe the last shot from the first usage)
How can I use the ZXing scanner component for Xamarin.Forms on different pages without turned on camera for the whole camera usage?
thx


how to access SelectedTextRange property in xamarin forms

$
0
0

i tried to get value using MessagingService on button click but not able to get the value as its null showing on debugging
MessagingService.Current.Subscribe("getSelectedText", async (m) =>
{
App.Logger.TrackPage("called get SelectedText");
Control.TextInRange(Control.SelectedTextRange);
});

Xamarin.Forms Feature Roadmap

$
0
0

This roadmap outlines our anticipated feature releases.

Are there things you don't see here that you feel strongly deserve a spot? Make your voice heard and open a proposal on the Xamarin.Forms Evolution forum.

Primary Focus

Quality is top of the list. This means stability and performance first and foremost. Xamarin.Forms has been swiftly adopted as a preferred tool for delivering production apps in addition to rapid prototypes. Our focus and priorities are to support the Xamarin.Forms community in those areas. In the release schedule below, we've highlighted how and where we are making those investments.

A Note About Bugs

As this thread is primarily about the feature roadmap, we anticipate the important question "what about ___ bug"?! Improving quality by addressing bugs is huge priority and ongoing focus for the team, in addition to improve our communication across the board.

Disclaimer

We cannot predict the future and how everything will shake out. Things will change. Timing may be adjusted due to priority changes, in pursuit of quality standards, or any number of other really good reasons that we will strive to proactively and openly communicate.

The Features Roadmap

Milestone Release Date
2.3.3 December 2016
2.4.0 February 2017
2.5.0 May 2017

2.3.3 - December 2016

Native View Declaration - Feature
Native view declaration allows you to add bindable iOS, Android, and Windows views directly to XAML. Rather than having to write a custom renderer, you can simply add the control directly to XAML with no additional configuration. This not only works with stock platform controls, but custom controls as well.

Platform-Specifics - Feature
Platform-specifics allow you to take advantage of native functionality that is only available on select platforms that Xamarin.Forms targets from shared code.

UWP Blur Support (3rd party nuget) - Feature
Adds the UWP blur platform-specific.

2.4.0 - February 2017

Bindable Picker - Feature
Adds data binding to the Picker control, specifically the following properties:

  • ItemSource

  • SelectedItem

https://github.com/xamarin/Xamarin.Forms/pull/515

Accessibility (A11y) Support - Feature
Proposal
Adds accessibility support to Xamarin.Forms by exposing the underlying accessibility features on iOS, Android, and Windows 10.

CarouselView v1 Stable - Feature
CarouselView was introduced at Xamarin Evolve 2016 and has been in prerelease ever since. v1 brings stability and performance improvements.

Xamarin.Forms for macOS Preview - Feature
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

Fast Renderers - Performance
Optimize built-in and custom view renderers to streamline view creation and improve performance.

Startup Time Improvements - Performance
Improve the startup and initialization time for Xamarin.Forms apps.

Compiled Native Views - Enhancement, Performance
Bring native view declaration to XAMLC, so users don't have to opt-out of XAMLC in PCLs where pages use native view declaration.

OnIdiom Support for Desktop (UWP) - Enhancement
Developers have lots of options when it comes to configurability based on operating system (Android, iOS, UWP, etc.), version (9, 10, etc.), and idiom (mobile or tablet). This adds Desktop as an OnIdiom for UWP developers.

https://github.com/xamarin/Xamarin.Forms/pull/420

XAMLC Enhancements - Enhancement, Performance
Approaching full support for currently supported XAML features. Compile time support for all value providers.

Deprecation of iOS 6/7

Deprecation of WP8

2.5.0 - May 2017

Xamarin.Forms Embedding - Feature
Embed Xamarin.Forms into a native Xamarin.iOS, Xamarin.Android, or Windows 10 app.

Xamarin.Forms for macOS - Feature
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

MenuPage - Feature
Alternative to the MasterDetail page, but rendered as a platform-specific menu that makes creating flyouts easy.

Cut down on GPU overdraw for Android - Performance
Try to avoid overdraw on Android where possible to improve performance.

Reduce native views created - Performance
Cut down on backing native views created for Xamarin.Forms, as noted by Miguel in #42948.

Layout Compression - Performance
LayoutCompression allows multiple layers of Xamarin.Forms layouts to be packed into a single native one.

Prism-Like URI Navigation Routing - Enhancement
Navigate to a page using Uri navigation, similar to what Prism does.

NavigationService.NavigateAsync("ListPage/DetailPage?id=1");

Single DLL - Enhancement
Ship Xamarin.Forms as a single DLL to improve startup performance and assist the linker.

Open Source Contributions

As noted above, the Xamarin.Forms Evolution forum is the place to start.

How to upload the download files into dropbox in Xamarin forms IOS?

$
0
0

In my XAMARIN forms Application in the IOS, I wanted to upload the locally downloaded files into a dropbox. I use Dropbox Core API iOS SDK component for this. [https://components.xamarin.com/gettingstarted/dropboxcoreapiios](by following this article). I successfully linked the dropbox account with the App in the dependency service.

if (!Session.SharedSession.IsLinked)
{
 UIWindow window = UIApplication.SharedApplication.KeyWindow;
 UIViewController viewController = window.RootViewController;
 Session.SharedSession.LinkFromController(viewController);
}

It creates the folder Apps/ApplicationName in the dropbox. Then I try to upload a local download file into dropbox wth an another dependency service using below code
var restClient = new RestClient(Session.SharedSession);
string dropboxPath = Session.RootDropbox;
restClient.UploadFile(filename, dropboxPath, null, localPath);

filename is name of the file, dropboxPath = dropbox and localPath like as
/var/mobile/Containers/Data/Application/D4DF47BF5-3A0E-4177-A48E-0D3C245774F1/Documents.

Nothing will be upload after this. Is it a correct way of approach? Please suggest me a solution

Pass binding from control to custom view "Sequence contains no matching element"

$
0
0

Hello,

everytime i try to bind the LabelText property in xaml from my custom cell i get the error "Sequence contains no matching element".
I really would like to make the binding via xaml work because i would like to do it without the x:name property and code behind.

controls:GridCell x:Name="Cell"
LabelText="{Binding ExampleText}" />

If i set the binding via code behind it works without any problems. Like this:

Cell.SetBinding(Cell.LabelTextProperty, "ExampleText");

My custom cell looks like this:

<cells:CellBase.View>
    <Grid HorizontalOptions="FillAndExpand"
          Padding="15, 15, 5, 5"
          VerticalOptions="FillAndExpand">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label Grid.Column="0"
               BindingContext="{x:Reference Self}"
               HorizontalOptions="Start"
               Text="{Binding LabelText}" />
    </Grid>
</cells:CellBase.View>

the partial class to the GridCell

    public BindableProperty LabelTextProperty = BindableProperty.Create(propertyName: "LabelText",
                                                                returnType: typeof(string),
                                                                declaringType: typeof(GridCell),
                                                                defaultValue: string.Empty,
                                                                propertyChanged: OnLabelTextPropertyChanged);

    public GridCell()
    {
        InitializeComponent();
    }

    public string LabelText
    {
        get { return (string)GetValue(LabelTextProperty); }
        set { SetValue(LabelTextProperty, value); }
    }

    private static void OnLabelTextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
    {
        var gridCell = bindable as GridCell;
        gridCell.OnPropertyChanged("LabelText");
    }

Does anyone know how to solve this problem?
Or maybe is there any other way to expose an property from an Control on a custom view? The idea behind this view is to have an reusable cell that could later derive to an PickerCell, DatepickerCell, ... The derived cells only have to fill the second column of the grid and also expose its properties.

Regards
Malte

Need to put HTML into a Label

$
0
0

I am using Xamarin.Forms and the Label view. I use the FormattedText (FormattedString class) to put formatted text in the Label. My goal here is to be able to convert HTML to a FormattedString.

In Xamarin.Android I have acces to Html.FromHtml() wich returns a ISpanned. Is there a equivalent for Xamarin.Forms ?

I cannot really use a WebView since my goal is to have multiple labels populated from HTML. If I use a WebView, I would be forced to do the whole page in HTML and not use Xamarin.Forms views/controls.

Thanks,
Max.

How can I customize the color in switch?

$
0
0

I'm using xamarin.Forms and want to customize the color of the switch? I found on forum to customize the switch but it seems to be not working.
Below is the code :
[assembly: ExportRenderer(typeof(Xamarin.Forms.Switch), typeof(CustomSwitchRenderer))]
namespace EVGMobileSolution.Droid.Custom_Renderer
{
public class CustomSwitchRenderer : SwitchRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Switch> e)
{
base.OnElementChanged(e);

        if (Control != null)
        {
            //Control.TextOn = "Si";
            //Control.TextOff = "No";
            Android.Graphics.Color colorOn = Android.Graphics.Color.Maroon;
            Android.Graphics.Color colorOff = Android.Graphics.Color.LightGray;
            Android.Graphics.Color colorDisabled = Android.Graphics.Color.Gray;

            StateListDrawable drawable = new StateListDrawable();
            drawable.AddState(new int[] { Android.Resource.Attribute.StateChecked }, new ColorDrawable(colorOn));
            drawable.AddState(new int[] { Android.Resource.Attribute.StateEnabled }, new ColorDrawable(colorDisabled));
            drawable.AddState(new int[] { }, new ColorDrawable(colorOff));

            Control.ThumbDrawable = drawable;
        }
    }

}

Can anybody let me know what I'm missing here.

How to draw on an image and save?

$
0
0

Hi guys,

Im working on a little app that requires a user to take a picture and then draw on it (like paint). I have been at this for a little while now and keep running into a problems.

How would you recommend handling this?

At the moment I am aiming for iOS only so I am using a custom renderer to creating a UIView that I can draw on. So thats fine and works (has undo, clear, change colour + size). Now Putting a background image onto this view will not work due to when Draw.Path etc I need to SetNeedsDisplay(), this will keep reloading the image. I only want to draw on the image and may even add this view into a scrollview to allow zooming etc.

Is there anyway I can get around this? If you need any more info please comment to let me know. I hope I have explained that so it is as least understandable!

Edit:
Should have also said that I have got code to save the view as a image, so its mainly just how to get the image behind the drawing view (and able to save it all as a image).

Cheers all,
Alex


TableView with long action-menu and items?

$
0
0

Hello!
I need create fullwidth-in-table-swipe menu like this? With images?
Have Xamarin.Forms any standart components for it? Or other solution?

Update: ListView show only menu without images, and only two items. If i have more items - it show first and button with text "More". I need very different behavior :-)

contentpage inherit from custom basepage

$
0
0

Hi

I have a basepage class that inherits from contentpage. Now I want every other page to inherit from my basepage instead of contentpage. How Can I do this?

Can not resolve reference: System.EnterpriseServices.Wrapper.dll

$
0
0

I have a Xamarin Forms Solution in Visual Studio. But everytime I try to compile the iOS project I got the following error message:

Can not resolve reference: /Users/user/Library/Caches/Xamarin/mtbs/builds/QSMobil.iOS/3b412dbb137e0cd8903009453a101181/bin/iPhoneSimulator/Debug/System.EnterpriseServices.Wrapper.dll ProjectName.iOS C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 696

I read a lot of updating my build server... But both the Mac (Xamarin Studio) and the Windows PC (VS) are up to date.
By the way it's possible to build the Android version of the app.
Maybe someone could help me?

How to organize page change?

$
0
0

How to organize the change pages using MVVM pattern and bindings? I can not find a sensible description. A method that I used to do it in WPF in Xamarin not work. :( Show working example please. Just be sure to meet MVVM. No handlers, only commands and bindings.

Icon image on Toolbar item in xamarin Forms

$
0
0

Hi,
I'm creating all forms UI with the code using the Shared project. I want to add the icon image to the toolbar item. Can anyone guide me how can I achieve the same ? I could not find a suitable example in the docs section of Working with images. They mostly deal with the Local and Embedded Images. The sample code should work for all the platforms.

Thanks

Xamrian Form Portable

$
0
0

I am using the Xamrain forms Portable How can I Restart the Application ??

Application windows are expected to have a root view controller at the end of application launch!

$
0
0

Cry.

Suddenly my app I'm working on doesn't work anymore -> I'm now getting the following crash when I start my app:

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch

Now, I've read the Stable release notes which say this

[Upstream change] [iOS] iOS 9 has stricter requirements for setting a RootViewController. "Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch". Possible workaround: Set the Window.RootViewController property in the AppDelegate.FinishedLaunching() method. (See the troubleshooting guide for additional details.)

Ok . not good nor do I know why ...

Checking the guide for help .. it says this :

This is error is being raised because app Windows are expected to have a Root View Controller at the end of application launch and your existing app doesn't.
Setup RootViewController property of app Window in FinishedLaunching method in AppDelegate class to point to a View Controller in your app's UI.

Ok .. so I want to try this but I have no idea what View Controller should I use? In fact, I have no idea if i even have any!

I've only got a few classes which inherit from ContentPage. I've not manually made any View Controllers :(

Can anyone help, please? It's very frustrating because I cannot run the simulator anymore to test my app!


Parse XML SOAP body

$
0
0

I am getting this edited SOAP packet back from a web service:

I have changed the "<" to a "|" otherwise the XML gets eaten here.

|WSSC_Get_JobsResponseA>
|ScanID>|item>F21CCE6A6F948545890560A5762E74DA|/item>
|item>59EF27C98EC79341B68DD60ADEF6AC76|/item>
|/ScanID> |ScanDeviceOut>|item>REL003|/item>
|item>REL003|/item>
|/ScanDeviceOut> |JobRef>|item>S05208A|/item>
|item>S05209A|/item>
|/JobRef> |JobType>|item>CO|/item>
|item>CO|/item>
|/JobType> |CreationDate>|item>2017-01-13|/item>
|item>2017-01-13|/item>
|/CreationDate> |CreationTime>|item>11:03:14|/item>
|item>15:30:23|/item>
|/CreationTime> |ScanNote>|item>Box Test 3|/item>
|item>Box Test 4|/item>
|/ScanNote> |Split>|item>0|/item>
|item>0|/item>
|/Split> |Chunksent>1|/Chunksent>
|TotalChunks>1|/TotalChunks>
|Recordssent>2|/Recordssent>
|/WSSC_Get_JobsResponseA>

Whatever Class definition I try I cannot get XmlSerializer to deserialize it.

Any ideas would be welcome.

ScrollView not scrolling when translation is set

$
0
0

Hi everyone,

i have a ScrollView in my app, which i translate on certain events. My problem is, the ScrollView is scrollable when set to its original position (TranslateY = 0) but its not scrollable when translated (TranslateY = some Value). This is only a problem on Windows UWP. Android and iOS are working fine. On Windows 10 Desktop the ScrollView can't be scrolled by mouse wheel, but the scroll bar is working. On the Windows 10 Phone Emulator, nothing is working to get the ScrollView scrolling.

I built a small Sample App to demonstrate the issue. The app only contains the Xamarin Forms xaml template with addition of this code:

public App()
        {
            InitializeComponent();

            string text = string.Empty;
            for (int i = 0; i < 100; i++)
            {
                text += "text\n";
            }

            MainPage = new ContentPage()
            {
                Content = new ScrollView()
                {
                    TranslationY = 1,
                    Content = new Label()
                    {
                        Text = text
                    }
                }
            };
        }

If this TranslationY property is set to 1, the ScrollView is not scrollable, if set to 0 it works. This behaviour is also true if the property changes its value at runtime, by some event.

Any suggestions ? Is this a known issue?

Thx in advance

getting width of View when making custom renderer for Android TableLayout

$
0
0

Hi, I'm making a custom renderer for Android TableLayout.
What I want to do is that making TextView's backgound which has width size proportional to TextView's width size.

Here is the sample code.

FrameLayout frame = new FrameLayout(Context);
TextView textView = new TextView(Context);
Android.Views.View background = new Android.Views.View(Context);

textView.Text = "HI";
frame.AddView(textView, LayoutParams.MatchParent, LayoutParams.WrapContent);

background.SetBackgroundResource(Resource.Drawable.Border);
frame.AddView(background, LayoutParams.MatchParent, LayoutParams.WrapContent);

Here, I want to change the width size(LayoutParams.MatchParent in frame.AddView(background, LayoutParams.MatchParent, LayoutParams.WrapContent)) to certain value that proportional to width size of textView.

eg. if an width of textView is 10, I want to set the width of background as 4.

But if I try to getting width value of textView by textView.Width, the value is 0.

So, I don't know how to get the value of width of View, in this case TextView.

please give me some idea.

TabbedPage: Icon next to Title?

$
0
0

Its possible to do it in Android?

My code:

TabbContainer.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:TabbedPageTest"
             x:Class="TabbedPageTest.TabbContainer">
  <local:Tabb1 Icon="icon1.png"/>
  <local:Tabb2 Icon="icon2.png"/>
</TabbedPage>

Tabb1.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TabbedPageTest.Tabb1"
             Title="Tabb 1">
  <Label Text="Tabb1" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>

(the same in Tabb2.xaml)

How to handle the result of StartActivityForResult in Forms

$
0
0

In the Android specific code of my Xamarin.Forms project, I use the following code to request the user to turn Bluetooth on:

const int RequestEnableBt = 2;
var context = Forms.Context;
var activity = (Activity)context;
var intent = new Intent(BluetoothAdapter.ActionRequestEnable);
activity.StartActivityForResult(intent, RequestEnableBt);

The user can either accept or deny the request.
In Xamarin.Android the result is handled in Activity.OnActivityResult().
Is there a way to handle this in Xamarin.Forms?

Viewing all 89864 articles
Browse latest View live


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