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

Setting the BindingContext of TabbedPage child pages?

$
0
0

I need all the child pages to use the same model as the parent TabbedPage. My Tabbed Page looks like this:

public class PersonPage : TabbedPage
{
    public PersonPage(int personId)
    {
        BindingContext = new PersonViewModel(personId);

How do I set the BindingContext of the child pages now? I've tried setting it like this:

  this.Children.Add(new CoreActivityPage() { Title = "Core", Model = this.Model });

However the Bindings I set in the CoreActivityPage don't do anything.

public class CoreActivityPage  : ContentPage
{
    public CoreActivityPage()
    {
        var lblName = new Label()
        {
            Text = "ffff"
        };

        lblName.SetBinding(Label.TextProperty,"Name");

        Content = new StackLayout()
        {
            Children = {lblName}
        };
    }

    public PersonViewModel Model
    {
        get { return BindingContext as PersonViewModel; }
        set { BindingContext = value; }
    }

}

Custom Renderer to Change Icon Position on NavigationBar Xamarin Forms

$
0
0

I already create Custom Renderer to add Logo in my Navigation Bar but the problem is The Logo is on the left of the Title , what i want is the Logo will be on the Right Side of the Title here is my Custom Renderer to do that

      protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
            {
                base.OnElementChanged(e);
                var bar = (Android.Support.V7.Widget.Toolbar)typeof(NavigationPageRenderer)
                        .GetField("_toolbar", BindingFlags.NonPublic | BindingFlags.Instance)
                        .GetValue(this);
                //  bar.SetNavigationIcon(Resource.Drawable.ic_myvalue);

                bar.SetLogo(Resource.Drawable.ic_myvalue);


            } 

any sugestion to do that ? or can we do that ? thanks

Hi i want to open a local PDF file in my WebView of xamarin forms Windows 8.1 App.

$
0
0

Hi i want to open a local PDF file in my WebView of xamarin forms Windows 8.1 App.
I am able to open the PDF file if the path is an online source but am unable do to so using the local path. Here is the code that I have used.
Note:- Browser is the name of the WebView i have used.
string path = "ms-appdata:///local/13/13.pdf"; Browser.Source = path;

How do I view the full map on Android when using a custom renderer?

$
0
0

Hi all,

When creating a content page with a map on it, you end up with a full screen map that, when zoomed out completely, allows you to view the top of Greenland.

 <StackLayout Margin="0">
      <m:Map />
 </StackLayout>

When adding a - for demo purposes rediculous - margin, you cannot view scroll to the top of Greenland anymore. (Same goes for Antarctica)

 <StackLayout Margin="100">
      <m:Map />
 </StackLayout>

The same holds when you place the map in a layout, as described in the documentation and give it a HeightRequest

I was wondering if this is as designed, or if this is a bug? If it is as designed, how can we specify the bounds / viewport in such a way that you can still view the entire world, as can be done in the first code snippet?

While the above doesn't use a custom renderer, we are using one for Android as we need to display a custom map. If there is a solution using the GoogleMap, we're happy as well. :)

Custom GeoLocation on Xamarin forms

$
0
0

Is there anyway to customize the geolocator to show the custom co-ordinate we are given, using customrenderer or anything.

Whenever geolocation button clicked it should move to the custom co-ordinate and zoom level we given. Thanks

Implement Payment gatway in xamarin forms

$
0
0

Hello xamarin guys,
i want to need a payment gateway Plugins for xamarin forms, anybudy have an idea for simple payment gateway.

Problem with alignment with grid and frames.

$
0
0

I have a problem with alignment in grid. It's about 1px different (1 of 3 bubbles has wrong render), the code is the same in all bubbles. I can't post screenshot because i'm new in forum, but framebackground sometimes behave like has 1px right margin.

frame.HorizontalOptions = LayoutOptions.End;
frame.VerticalOptions = LayoutOptions.Fill;
frameBackground.HorizontalOptions = LayoutOptions.End;
frameBackground.VerticalOptions = LayoutOptions.End;
gridForBubble.HorizontalOptions = LayoutOptions.EndAndExpand;
gridForBubble.Children.Add(frameBackground, 0, 0);
gridForBubble.Children.Add(frame, 0, 0);

I tried change frameBackground to BoxView, but was the same error.

frameBackground is a little frame with radius = 0 for rectangle corner.
frame is a big frame with radius = 15 which has a label inside.

Margin in both =0.

How to use Segmented Control in xamarin forms IOS?

$
0
0

I have xamarin project it is portable not shared. In case of IOS i want to put segmented control there but in case of android tabbedpage.
In shared project we can use '#if IOS' and '#if Android'. But it is not possible to use it in PCL. What is the alternative for that?


Adding padding to Hamburger Menu Icon

$
0
0

We are using the master detail page to implement navigation drawer hamburger menu.Now we are styling the action bar in a native way using a theme.

<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/MyActionBar</item> <item name="android:homeAsUpIndicator">@drawable/back</item> </style>' '<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> <item name="android:background">#06336E</item> </style>

However on using this the hamburger menu icon gets completely left aligned with absolutely no padding.I am unable to set a padding to it.
We are using the Icon property of the menu page to set the hamburger icon image.

Xamarin Forms - Displaying a local html file in webview on Android

$
0
0

Sounds simple but for some reason, it's not working for me. I have following code:

string rootPath = DependencyService.Get<IBaseUrl>().Get();
var source = new UrlWebViewSource
{
    Url = System.IO.Path.Combine(rootPath, "Index.html")
};

browser.Source = source;

and the code for IBaseUrl implementation on android is

public class BaseUrl : IBaseUrl
{
    public string Get()
    {
        return "file:///android_asset/Content/";

    }
}

Also tried removing 'Content' from the url but still not working.

java.lang.OutOfMemoryError

$
0
0

Getting this error when trying to run one of the Xamarin.Forms navigation samples from GitHub (MasterDetailsPage)

Severity Code Description Project File Line Suppression State
Error java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing 'java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.3\lib\dx.jar" --dex --no-strict --output obj\Debug\android\bin D:\MasterDetailPage\Droid\obj\Debug\android\bin\classes\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.0\mono.android.jar" obj\Debug\lp\0\jl\formsviewgroup.jar obj\Debug\lp\10\jl\bin\classes.jar obj\Debug\lp\11\jl\bin\classes.jar obj\Debug\lp\12\jl\bin\classes.jar obj\Debug\lp\13\jl\bin\classes.jar obj\Debug\lp\14\jl\bin\classes.jar obj\Debug\lp\15\jl\bin\classes.jar obj\Debug\lp\16\jl\bin\classes.jar obj\Debug\lp\17\jl\bin\classes.jar obj\Debug\lp\18\jl\bin\classes.jar obj\Debug\lp\19\jl\bin\classes.jar obj\Debug\lp\20\jl\bin\classes.jar obj\Debug\lp\21\jl\bin\classes.jar obj\Debug\lp\3\jl\arch-core-common.jar obj\Debug\lp\4\jl\arch-lifecycle-common.jar obj\Debug\lp\5\jl\bin\classes.jar obj\Debug\lp\6\jl\bin\classes.jar obj\Debug\lp\8\jl\bin\classes.jar obj\Debug\lp\9\jl\bin\classes.jar C:\Users\me\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Basement\8.4.0\embedded\classes.jar' MasterDetailPageNavigation.Droid

I tried setting android:largeHeap to true in the AndroidManifest.xml

<application android:label="MasterDetailPageNavigation" android:largeHeap="true">

But the error didn't go away

I also tried to set the Java Max Heap Size to 1G in the Android Advanced Options under the project properties - the project builds without errors but that's about it, the emulator doesn't launch (or if I have it open nothing happens within it - the app doesn't start)

Android WebView Renderer GoBack()

$
0
0

Hi,

I have some problems while overriding the "GoBack()" method in WebViewRenderer.

I created a custom web view renderer in IOS: public class ExtendedWebViewRenderer : Xamarin.Forms.Platform.iOS.WebViewRendere and override the GoBack and CanGoBack methods.

Now I want to do that stuff in android too:
So, I created a custom renderer: public partial class ExtendedWebViewRenderer : Xamarin.Forms.Platform.Android.WebViewRenderer

But the renderer paret has no method like "GoBack" or "CanGoBack" to override. Why? How can I override those methods like in iOS?

Any idea what the problem is?

Custom picker

$
0
0

I need to design an custom picker , that supports android as well as IOS . Is it possible to do that ? If any third party library available ?

How to open app specific *.gcf files with my Xamarin.Forms app

$
0
0

Hi
I would like to be able to open files with the extension "* .gcf" with my Xamarin.Forms app (for now only for Android platform). The file contains configuration settings in JSON format. If the user taps on the file, the settings should be read out and saved and then a message will be displayed.

I read that it can be implemented on Android using Intent Filter.
I added a new Activity (ConfigFileActivity) to the Android Project and defined the following attribute:

[IntentFilter(new string[] { Intent.ActionView }, Categories = new string[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "content", DataPathPattern = ".*\\.gcfdri", DataMimeType = "application/octet-stream")]

But if I want to open a * .gcf file, I get the message that there is no app installed that can open this file.

  • What is still missing? How do I register the file extension?
  • How can I read the JSON file?
  • Is it best practice to use a separate activity?

Thank you for tips!
Michael

ContentView and Gesture

$
0
0

Hi guys,
I have a strange problem with ContentView and Gesture. Like in this component DLToolkit.Forms.Controls I want to crop an image.

If I create a new project and add the component, it's working fine. If I add it to my existing solution, PinchGestureRecognizer and PanGestureRecognizer don't work. It means the gestures are correctly added to the ContentView but they don't be fired. In the same project, I created another simple component as Grid and I added Image with TapGestureRecognizer and it's working fine.

I don't have any ContentView renderer. Do you have any ideas?
Thanks in advance.


Designer: Images in ListView

$
0
0

Hi, I am trying to use the Visual Studio for Mac designer (iOS, V7.3.2) and I have it working so far that it renders a listView with data.

I have some testdata that I use for design time that includes images. Images are loaded via a UriImageResource. Yesterday everything worked fine and my images showed up in the designer. This morning I opened the same xaml file in the designer and the list displayed data but the images didn't show up any more. I did a rebuild and everything but no images. I also checked the VS log files, but I don't see any errors. Any ideas on how to solve this?

Thanks!

Relative context for tap gestures

$
0
0

I want to bind to command from context outside of my data template. I may do it using Button control and EventToCommand behavior. However I haven't found a way to do it for tap gestures.

Here is a small example when I want to present a small tree structure of tags (tag only has name and children properties). My intention is to go to edit page after clicking tag name without a need to have special button

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"             
                 xmlns:controls="clr-namespace:MyProject.Controls;assembly=TaskChaos"
                 xmlns:mvvm="clr-namespace:MyProject.Mvvm;assembly=TaskChaos"
                 prism:ViewModelLocator.AutowireViewModel="True"
                 x:Class="MyProject.Views.TagManagementPage"
                 x:Name="TagPage">
      <ContentPage.Resources>
        <ResourceDictionary>
          <DataTemplate x:Key="Tag">
            <StackLayout Orientation="Vertical">          
              <StackLayout Orientation="Horizontal">
                <Label Text="{Binding Name}" Margin="2">
                  <!--<Label.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding GotoEditTagCommand}" CommandParameter="{Binding }"></TapGestureRecognizer>
                  </Label.GestureRecognizers>-->
                </Label>
                <Button Text="Edit">
                  <Button.Behaviors>
                    <mvvm:EventToCommandBehavior CommandNameContext="{mvvm:RelativeContext TagPage}" CommandName="GotoEditTagCommand" CommandParameter="{Binding }" EventName="Clicked" />
                  </Button.Behaviors>
                </Button>
              </StackLayout>
              <controls:RepeaterView ItemsSource="{Binding Children}" ItemTemplate="{StaticResource Tag}" Margin="15, 2, 2, 2" />
            </StackLayout>
          </DataTemplate>
        </ResourceDictionary>
      </ContentPage.Resources>
      <controls:RepeaterView ItemsSource="{Binding Tags}" Spacing="2" ItemTemplate="{StaticResource Tag}">    
      </controls:RepeaterView>

    </ContentPage>

Any ideas how to make it work also for tap gestures?

Multiline text in SwitchCell

$
0
0

Hello. Can I make a multi-line text in the switch cell? Thank you for helping us.

Messaging center

$
0
0

Hi Guys,

I try to to use messaging center from platfomr andorid to .net standard project.

The messagin center send the message one time but the receiver is activated 2 times.

I have an andorid device version 5.1, i dont' know if this colud be usefull.

Here the piece od code od the receiver

MessagingCenter.Subscribe<string, string>("iMioDocPdaEntry.Android", "BARCODE_RECEIVED", async (sender, arg) =>
{
{
if (DocRigheView.attiva)
{
await RicercaArtBarCode(arg);
}
else
{
await RicercaCommBarCode(arg);
}
}
});

her bolwo ther sender

MessagingCenter.Send<string, string>("iMioDocPdaEntry.Android", "BARCODE_RECEIVED", result);

Xamarin.Forms 2.5 compatibility with older Xamarin.iOs

$
0
0

Hi everyone,
I'm updating nuget packages on my Xamarin.Forms app.
I had no problem updating to 2.5 for my Android project but I had some compilations issues on iOs, as 2.5 seems to be unsupported for my Xamarin.iOs version - 6.3 build 864.
For my Mac Agent I have an old Mac Mini with El Capitan (10.11.6), and that keeps me from updating my XCode any further than 8.0, and it seems like I need newer versions in order to update my Xamarin.iOs - which allows me to update .Forms to 2.5.
Is that correct? I haven't ever seen any of these constraints on Xamarin website, but I really couldn't compile any packages with newer versions. Right now I'm stuck at the later 2.3 ones, I also got some runtime errors and I suspect this is due to the version difference between Xamarin.Forms.Portable and Xamarin.Forms.iOs versions.

Any pointers?
Thanks in advance!

Viewing all 58056 articles
Browse latest View live


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